Trigger click event

Is there a way to trigger the click event on a ion-select element?

What im looking for is to get the alert with the options through a button element.

3 Likes

Any solution? I met with the same problem.

I’m facing the same problem. Searching through the docs it seems like there is already a solution to this but it isn’t fully documented yet.

Try this:

import {Component} from '@angular/core';
import {Select} from 'ionic-angular';
import {ViewChildren, Renderer} from '@angular/core';

@Component({
  templateUrl: 'template-url'
})
export class MyClass {
  @ViewChildren(Select) selectComp;
  constructor(private _renderer: Renderer){
  }

  openList(){
      var evObj = new Event("click", {bubbles: true});
      this._renderer.invokeElementMethod(
        this.selectComp.last._elementRef.nativeElement, 'dispatchEvent', [evObj]);
  }
}

If you have only one Select component then you could just use ViewChild instead of ViewChildren

1 Like

l user jquery, it’s useful in chrome but not work in ios device …