I an new in angularjs and I have json in my angularjs application, I want ng-switch to work when that json is not empty(it is an array). it's a large json and I'm talking about one part of it,is it possible with ng-switch? or I should set scope parameter in my controller? or some other ways that I do not know of
JSON
...,
"venues": [{"vid":"12",...},{"vid":"13",},{"vid":"14",..}],...
Markup
<div ng-switch on="team.venues" >
<ul ng-switch-when="venue is not empty">
<li ng-repeat="venue in team.venues">
{{venue.vid}}
</li>
</ul>
<p ng-switch-default>no venue</p>
</div>
You could directly use direct expression there like ng-switch-when="team.venues.length > 0 && team.venues"
.
Markup
<div ng-switch on="team.venues">
<ul ng-switch-when="team.venues.length > 0 && team.venues">
<li ng-repeat="venue in team.venues">
{{venue.vid}}
</li>
</ul>
<p ng-switch-default>no venue</p>
</div>