B
B
bogdan_nsk2020-04-17 04:11:01
Angular
bogdan_nsk, 2020-04-17 04:11:01

Simulating clicking on multiple Angular 8 buttons?

When you click on the button, the elements should open / close
I made such a code, but it only works on one element. Items are added dynamically

component
@ViewChild('loginButton') loginButton: ElementRef<HTMLElement>;

btnClick(){
  console.log(this.loginButton.nativeElement);
   let el: HTMLElement = this.loginButton.nativeElement;
    el.click();
}

.html
5e9901c3b9733687714464.png

looks like
5e99013eda4e4361192916.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Shvets, 2020-04-17
@bogdan_nsk

https://stackblitz.com/edit/angular-8-viewchildren...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question