GustavoA
GustavoA

Reputation: 79

How to return an array after a function?

I manage to make my array to work on the console.

When I click the button the array shows on the console, but not on my HTML.

TS:

jogar(){
 for(var u=0;u<6;u++){        
     this.y = Math.ceil(Math.random()*59+1);
     this.random.push(this.y);           
    };
};

HTML:

<ion-card-content>        
    <button ion-button color="secondary" (click)="jogar()">Jogar</button>
    <p>{{random}}</p>        
</ion-card-content>

How can I make it work?

Upvotes: 0

Views: 84

Answers (1)

Roman C
Roman C

Reputation: 1

you should use ngFor directive to show the values

 <p *ngFor="let r of random">{{r}}</p>

Upvotes: 1

Related Questions