arrays - AngularJs: ngrepeat stepping through an ordered item -
i new angular , web programming in general. i'm on project client who's primary function processing customer orders. valet directed single page there service call returns customers specific order. single order can contain many items(and in case these items can different retailers i.e 1 item amazon, 2 ebay, etc.)
what need have page iterate through complete order , display 1 item @ time. valet verify/place order item, , click 'next' move on next item in order until completion. i'm using ng-repeat , displays entire order, question how limit single item @ time? ng-repeat correct directive use?
thanks in advance , let me know if can clarify anything.
i think ng-repeat not answer, in case better iterate through items using index or creating currentitem on scope , binding it.
since first option easier demonstrate (but not more elegant one) made plunkr: http://plnkr.co/edit/r1639k71qicioooegz84?p=preview
<div ng-show="currentitemindex < order.items.length"> item n. {{order.items[currentitemindex].number}}<br/> description<br/> {{order.items[currentitemindex].description}}<br/> <button ng-click="nextitem()">next</button> </div> please take , see if that's looking for, also, exercise, fork plunkr , make work binding directly $scope variable can this:
<div ng-show="currentitem"> item n. {{currentitem.number}}<br/> description<br/> {{currentitem.description}}<br/> <button ng-click="nextitem()">next</button> </div> see how that's more easy read? , allow maybe retrieve order items server 1 one, if that's ever case, lol.
on nextitem() can add required validation well.
hope helps
Comments
Post a Comment