Can someone help on how to re-write the below code in Angular. I am having problem in handling filters
ng-repeat="data in myController.data | filter:{filterFlag:'true'}"
Can someone help on how to re-write the below code in Angular. I am having problem in handling filters
ng-repeat="data in myController.data | filter:{filterFlag:'true'}"
AngularJS
Lets say you have an array of objects (in your case named data) in your myController i.e.
this.data = [
{id: 1, name: 'Oscar', age: 36},
{id: 2, name: 'Nina', age: 36},
{id: 3, name: 'Alex', age: 39},
]
And you want to filter out people with the age 36, you could iterate over it in the template like this:
<div ng-repeat="data in myController.data | filter:{age:36}">
{{data}}
</div>
Angular
In any case, filters are expensive. Thats why they are considered bad practice, thats why you are not recommended to use it in Angular. The style guide says, you ought to filter out the objects in the controller, rather than in the template. You might want to consider doing the same in AngularJS. You could write a method which does the job.
For more go to ... ng-repeat :filter by single field