Motion Motion - 3 months ago 8
HTML Question

How to check size of array in Angular Js?

I have an Array .for example:



CaptionList = [
{ caption: "John" },
{ caption: "Jack" },
{ caption: "Jounior" }
];





I was created an Tag Input Control and fill it by CaptionList.like this,



<div class="input-group">
<div id="divItems" style="overflow-y: auto; overflow-x: hidden; height: 50px;" class="form-control">

<span ng-repeat="item in CaptionList " class="item">
<span><i id="imgDelete" class="fa fa-remove" ng-click="remove($index)"></i>&nbsp; {{item.caption}} </span>
</span>

</div>

</div>





Now,I want check if lenght of CaptionList is less than 1 and more than 3 it shows an error message . any help ?

Answer
<div ng-if="CaptionList.length < 1 || CaptionList.length > 3">Error Message</div>
Comments