I know that ng-repeat only works on the array
My problem occurs when I do not know if I have an object received from the server, then the array or the object is only.
I must decide on dynamically whether it is array or object, and only then this array uses NG-repeat
My question is most of the use of ng-repeat with condition What's the best way - if only the object is an array?
I tried to solve this problem:
& lt; Div ng-if = "array.isarru (myoze)" ng-repeat = "item in ios" & gt; & Lt; Tax - Some Goods Items = 'Items' & gt; & Lt; / Do-some-stuff & gt; & Lt; / Div & gt; & Lt; Do-some-stuff ng-if = "! Array.isArray (myObj)" item = 'myObj' & gt; & Lt; / Do-some-stuff & gt;
But this is not working.
ng-double priority is 1000 and ng-if priority is 600. Therefore, ng-repeat before and after NG-if its code is not working. Use this code:
& lt; Div ng-if = "Array.isArray (myObj)" & gt; & Lt; Div ng-repeat = "item in myObj" & gt; & Lt; Tax - Some Goods Items = 'Items' & gt; & Lt; / Do-some-stuff & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; Do-some-stuff ng-if = "! Array.isArray (myObj)" item = 'myObj' & gt; & Lt; / Do-some-stuff & gt;
Comments
Post a Comment