Using AngularJS 1.4.1. I had this markup with multiple calls to a custom directive:
<div ng-controller="SomeController"> <myDirective data="myData.Where('IsOpen',true)"></myDirective> <myDirective data="myData.Where('IsOpen',false)"></myDirective> </div>
myData is an array and Where() is an extension method that iterates over the array returning a new array containing any items from the original where the IsOpen property matches the bool value in the second parameter.
In the controller I set $scope.data like this:
DataService.getData().then(function(results){ $scope.data = results; });
Calling the Where() extension method from the directive like in the above markup was the problem. To fix this issue I moved the call to the extension method into the controller instead of the markup:
<div ng-controller="SomeController"> <myDirective data="openData"></myDirective> <myDirective data="closedData"></myDirective> </div>
and the new controller code:
DataService.getData().then(function(results){ $scope.openData = results.Where('IsOpen',true); $scope.closedData = results.Where('IsOpen',false); });
No Comments Yet