Motion Motion - 1 year ago 82
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 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>



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

Answer Source
<div ng-if="CaptionList.length < 1 || CaptionList.length > 3">Error Message</div>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download