AngularJs: multiple directives asking for isolated scope on
angularjs, javascript
Solution
According to your code, you don't need isolated scope to get attribute value. Just use this:
directivesModule.directive("capital", function ($parse) {
return {
link: function (scope, element, attrs) {
// get attrs value
attrs.capital
}
}
})
Problem
I created two directives: ``` directivesModule.directive("capital", function () { return { scope: { capital: "@" }, link: function () {} } }) directivesModule.directive("country", function () { return { scope: { country: "@" }, link: function () {} } }) ``` Next, I use them in the same element: ``` <div country="Russia" capital="Moscow"></div> ``` As a result, I get an error: `Error: [$compile:multidir] Multiple directives [capital, country] asking for new/isolated scope on: <div country="Russia" capital="Moscow">` How do I get the attribute values without scope? These directives will not necessarily be used in conjunction.