如何获得嵌套ng-repeat的长度

时间:2016-08-17 08:59:26

标签: angularjs angularjs-ng-repeat string-length

嗨我有嵌套数组如何获得嵌套数组的长度?它需要显示

2 个答案:

答案 0 :(得分:0)

<div ng-repeat="movie in movies">
  <div ng-repeat="actor in movie.meta.actors" > 
    <div ng-if="movie.meta.actors.length ==1"> Actor: <div>
    <div ng-if="movie.meta.actors.length !=1"> Actors: <div>
    <text>{{actor.name}}<text>
  </div>
</div>

答案 1 :(得分:0)

尝试使用ng-switch

<div ng-repeat="movie in movies" ng-switch="movie.meta.actors.length > 1">
  <div ng-repeat="actor in movie.meta.actors"> 
     <div ng-switch-when="true"> Actors: <div>
     <div ng-switch-default> Actor: <div>
     <text>{{actor.name}}<text>
  </div>
</div>

这是一个有效的jsfiddle http://jsfiddle.net/n3ekmpn6/