Cycle for in Ionic view?

0

I had a question and that is that I want to print an element in the ionic view a number of times according to a numeric variable

let's say:

public numero = 4;

then in the view try doing a kind of cycle with *ngFor but without results (because I usually use it with Arrays)

Then do some research and read about ngrepeat

I want to print a star according to the number I sent it, that is, if you sent it a four-star print

 <ion-icon ng-repeat="i in numero"  color="yellow" ios="ios-star" md="md-star" ></ion-icon>
    
asked by Wilfredo Aleman 21.05.2018 в 14:11
source

1 answer

1

try this, it should work Html:

     <ul>
        <li ng-repeat="i in getNumber(number)"><span>{{$index+1}}</span></li>
    </ul>

in the controler

  $scope.number = 5;
    $scope.getNumber = function(num) {
        return new Array(num);   
    }

I put a link where they explain it best: link

    
answered by 21.05.2018 / 14:55
source