如何限制NG重复中重复数量的项目.Angularjs



我正在使用联系卡。我需要在列表中添加名称和联系电话。但是条件是名称,只需添加2次接触。对于ex。

联系卡1

  1. name-a
  2. 名称b
  3. Contact-1
  4. Contact-2

每当我单击按钮时,我的名字就会添加到列表中,但有一定条件。我的代码是

<md-list-item ng-show="showContactList" class="md-2-line" ng-repeat="numbers in contactList track by $index" >
<i ng-show="numbers.type == 'test'" class="material-icons md-avatar-icon">textsms</i>
<i ng-show="numbers.type == 'CELL' || numbers.type == 'EXT'" class="material-icons md-avatar-icon">phone</i>
<div class="md-list-item-text" ng-class="{'md-offset': phone.options.offset }">
<h3>  {{ numbers.type }} </h3>
<p> {{ numbers.value }} </p>
</div>
<i class="material-icons md-avatar-icon add-rm-icon margin-right" ng-click="arrayText.push(numbers);">add</i>
</md-list-item>

您可以使用:

<div ng-repeat="item in items | filter:{visible: true} | limitTo: 50"> <p>{{item.id}}</p> </div>

{visible- true}将返回所有可见项目的列表

您可以查看AngularJS Docu,以获取有关过滤器过滤器的更多信息。http://docs.angularjs.org/api/ng.filter:Filter

最新更新