I'm trying to create a directive that accepts an array of objects and run ng-repeat to render them.
app.directive("rockers", function(){
return {
restrict : "E",
replace : true,
scope : {
items : '='
},
template : '<div>'+
'<span ng-repeat="item in items">{{item.name}} Rocks!</span>'+
'</div>'
};
});
In the controller, I set the scope with opjects:
app.controller("appController", function($scope){
$scope.scopedItems = [{name:"Aanny"}, {name:"Bonny"}, {name:"Danny"}];
});
And then, to call the directive I pass the scopedItems with filter, like this:
<div ng-app="myApp" ng-controller="appController">
Rockers:
<rockers items="scopedItems | filter:{name:'Bonny'}"></rockers>
</div>
Without using the filters in the HTML, everything works fine. When passing the filter I still get the results I want, but I'm also getting this error: "Uncaught Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!"
What am I doing wrong?
Here is a jsFiddle link to recreate the error.
Thanks!