I have an object attribute defined in an element directive, which itself is defined inside an ng-repeat directive:
<div ng-repeat="element in array">
<my-directive el-sel="{{element}}>
<something else>
</my-directive>
</div>
And this is myDirective:
app.directive('myDirective', function() {
return {
restrict: 'E',
scope: false,
link: function($scope, $element, $attrs) {
console.log('element:' + JSON.stringify($attrs.elSel));
console.log('href: ' + $attrs.elSel.href);
}
}
});
The console results are:
element:"{\"name\":\"a name\",\"href\":\"#something\"}"
href: undefined
What is the explanation for this behavior, and what am I doing wrong?
console.log($attrs.elSel);simply to check the data, whether that object is coming up as a string or in some other data type.