Reputation: 345
I'm iterating (ng-repeat) over a childArray of an existing loop with ng-repeat, but I want blank results to show on my child ng-repeat. Is there any way to do that? I have an element structure I want to be shown from the child ng-repeat.
The code looks like this :
<ng-repeat="row in parentArray"> <--- the parent array
{{row.name}}
{{row.date}}
{{row.place}}
<ng-repeat="option in row"> <--- the child array
Result : {{option.name}} <-- I still want result to show up
</ng-repeat>
</ng-repeat>
Upvotes: 0
Views: 138
Reputation: 2050
If i understand you correctly, you wanna show something if there is no option?
ng-repeat
only works with data. When there is no data, nothing is displayed. For this purpose you can use ng-if
or ng-show
/ ng-hide
Also it is very unclear for me at the moment, where the options are stored in the row
HTML
<ng-repeat="row in parentArray"> <--- the parent array
{{row.name}}
{{row.date}}
{{row.place}}
<div ng-if="row.options.length > 0">
<ng-repeat="option in row.options"> <--- the child array
Result : {{option.name}} <-- I still want result to show up
</div>
<div ng-if="row.options.length === 0">
<label>No Data</label>
</div>
</ng-repeat>
Upvotes: 2