Pritesh Bhoi
Pritesh Bhoi

Reputation: 1096

Click event using Class in Angular Ionic

I am using Highchrt and i want click on lengend on load.

I am using angular ionic so how can i click .highcharts-legend-item class in ngOnInit() {} function.

I want click tthis class on page is load with angular ionic.

In javascript $(.highcharts-legend-item).click(); but i dont knw in anular ionic.

The edit

Upvotes: 1

Views: 515

Answers (1)

Marcell Kiss
Marcell Kiss

Reputation: 556

If you're using Ionic, you're still in a browser, so you can use the standard html-js API.

Pure JavaScript Approach

document.querySelector('.highcharts-legend-item').click()

Angular Approach

Use ElementRef and click the element programmatically

ts:

 constructor(private elem: ElementRef){}

 ngAfterViewInit(){
    this.elem.nativeElement.querySelector('.highcharts-legend-item').click();
 }

Upvotes: 2

Related Questions