javascript - ng-repeat on non array object -
i know ng-repeat works on array.
my problem when don't know if object server, array, or object. need determine dynamically if it's array or object, , if it's array utilize ng-repeat.
my question best way implement using ng-repeat status - if object array?
i tried solve problem way:
<div ng-if="array.isarray(myobj)"ng-repeat="item in myobj"> <do-some-stuff item='item'></do-some-stuff> </div> <do-some-stuff ng-if="!array.isarray(myobj)" item='myobj'></do-some-stuff>
but it's not working.
ng-repeat priority 1000 , ng-if priority 600. ng-repeat execute first , ng-if.that's why code not working .use code:
<div ng-if="array.isarray(myobj)"> <div ng-repeat="item in myobj"> <do-some-stuff item='item'></do-some-stuff> </div> </div> <do-some-stuff ng-if="!array.isarray(myobj)" item='myobj'></do-some-stuff>
javascript arrays angularjs angularjs-ng-repeat angular-ng-if
No comments:
Post a Comment