0

I want to do something like this in angular 2(trigger rightclick-event in jquery)

('#element').trigger({
 type: 'mousedown',
 which: 3
});

just like you can trigger a click event like this

var element = <HTMLElement>document.elementFromPoint(corrected_x, corrected_y)
element.click()

Is that possible?

TamRock
  • 1,490
  • 1
  • 11
  • 27
  • 3
    Possible duplicate of [Angular 2 right click events?](http://stackoverflow.com/questions/41670017/angular-2-right-click-events) – Brandon Taylor Apr 25 '17 at 10:53
  • http://stackoverflow.com/questions/41670017/angular-2-right-click-events want to capture the event i want to trigger it on element. – TamRock Apr 25 '17 at 10:56

1 Answers1

0

Use can use emenet.click(). See the example where the first button triggers a click event on the second hidden button.

 @Component({
  selector: 'my-app',
  template: `
    <div>
      <button (click)="hiddenBtn.click()">Click hidden button</button>
      <button  #hiddenBtn (click)="hiddenBtnClick()" style="display:none"></button>
      Hidden button clicked: {{times}}
    </div>
  `,
})
export class App {
  times =0;
  constructor() {
  }

  hiddenBtnClick() {
    this.times++;
  }
}
Julia Passynkova
  • 17,256
  • 6
  • 33
  • 32