I have a simple question: I have an array of object which i iterate trough in "ng-repeat":
Object:
$scope.my objects= [
{ value: '1', text: 'lorem ipsum...1' },
{ value: '2', text: 'lorem impsum...2' },
{ value: '3', text: 'lorem ipsum...3' }
]
Now in my ng repeat i need to be able to set the status, so i have a select in which i have all available options:
Option from my Select:
$scope.select_option= [
{ value: 'confirmed', text: 'confirmed' },
{ value: 'rejected', text: 'rejected' },
{ value: 'cancelled', text: 'cancelled' }
]
I would like to filter which options to display for each item of my my main object. This is an example of which filter i woul like in my select repeat.
object.status == 'pending' && (object.start.getTime() >= new Date().getTime())
You can use two ways to do this:
While iterating on the dom element use ng-if (Recommended way):
<div ng-repeat="object in objects" ng-if="object.status === 'pending'> {object} </div>
Or else you can use an angular filters:
<div ng-repeat="object in objects | custom_filter"> </div>
where you write your custom filter.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.