我有这个代码。 $scope.counter = '1';
<div ng-repeat="cat in catadata">
<div ng-if="cat.TopCategoryID = 2" >
<div ng-if="counter = 1" >
<div class="feedsDisplay" ng-init="counter = counter + 1">
Creater Img:{{cat.CreatedBy_Profile.Picture.URI}}"
</div>
</div>
</div>
</div>
我想在 counter = 2
时停止循环,我只想显示 1 个结果。
ng-init="counter = counter + 1
{{counter}}
显示11111
它应该显示12345
最佳答案
您正在与 =
进行比较,而不是 ==
尝试这样
ng-if="counter == 1"
counter
的值为 string 。在计数器
前添加+
符号
尝试这样
ng-init="counter = +counter + 1"
关于javascript - 在 angularJS 中使用 ng-if 条件停止循环,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32652302/