1

I have:

button *ngFor="let button of buttons" (click)="changeValue()"

I have:

export class Home {

  howMany: number = 10;
  zoom: number = 5;

  buttons = [
    { howMany: 40, zoom: 10 }.
    { howMany: 100, zoom: 2 },
    { howMany: 23, zoom: 35 }
  ]

}

I have:

3 buttons on the screen.

How to create:

When I click button number 1: "howMany" change from 10 to 40 and "zoom" from 5 to 10

etc.

1 Answer 1

3

Here you go:

Template

<button *ngFor="let button of buttons" (click)="changeValue(button)">

TS

export class Home {

  howMany: number = 10;
  zoom: number = 5;

  buttons = [
    { howMany: 40, zoom: 10 }.
    { howMany: 100, zoom: 2 },
    { howMany: 23, zoom: 35 }
  ]

  changeValue(button) {
    this.howMany = button.howMany;
    this.zoom = button.zoom;
  }

}
Sign up to request clarification or add additional context in comments.

1 Comment

Awesome!! Thank you my friend!! :D

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.