I would like to loop though each item and display the values of each item. My problem is that while looping though each item using ng-repeat, I don’t want to add that additional div which has added to use the ng-repeat. Is there any way to use the ng-repeat without adding any div.
It should be possible when you write a custom directive that uses the link method to manipulate the data… You could end up with something like:
<div class="row item" ng-nested-repeat="(key,value) in items" data-ng-click="onClickItem(item)">
But in pure angular, you are iterating over a list withing a list, so you have to iterate each nesting yourself. I wouldn’t touch it I think keeping it like this produces cleaner and self-explanatory code.
Thanks for your quick response iwantwin. Can you please explain in brief how can we use the ng-nested-repeat custom attribute to loop through the list of items. Please give me some pseudocode because I am new to angularjs.
I’m sorry if I wasn’t clear about that! The ng-nested-repeat would be custom, so you would have to write your own directive to support this. The attribute does not come packaged nor do I know a directive that already implements your wish… I’m not really experienced in angular myself though, so wraping up a directive will take me some time, which I can’t spend right now. I will try to create such a directive this weekend (there must be a time where I have to learn writing a directive anyways), so please bear with the extra div for now and remind me next week (or I won’t be able to find the topic anymore… Probably :P) to share my first custom directive ( If I manage to pull it off that is…)