How to display "n" icons on view where n is int value of a variable


#1

This may be a noob question. I am currently learning Ionic and Angular in parallel and I was looking for a clean way to display to display a number of icons that is equal to an int stored in a variable that is set by a range.

I currently have my code set up to have the user set the range and then save that range on one state then on another state display an int value corresponding with that range.

How would I go about displaying a number of icons equal to that range? Would I just declare a function for when the state loads that takes the int value and then modify the view with “n” number if tags?


#2

Show us what have you done so far?


#3

Here is a quick example: http://play.ionic.io/app/3c638e14fc88

Here is my project so far: http://plnkr.co/edit/Tqfa1eVjel5z1fFrOkoQ?p=preview

For some reason plnker doesn’t want to place nice even though it runs fine on my browser(s), emulator, and android device.

I basically am interested if there is a quick ionic/angular way to display a number of ionicons equal to the value of notes.priority.

I am pretty new to angular and ionic-so my idea of just making a function in my notestore service to just edit the view based on on the notes.priority variable may be incorrect?


#4

You want to use ng-repeat. See this forked example: http://play.ionic.io/app/8112a203bba0