LoginSignup
4
2

More than 5 years have passed since last update.

Angularで操作された要素と別の要素のclickイベントを発火させる。

Last updated at Posted at 2018-02-20

意外と面倒だったので、メモ

親要素(.parent)のどこでenterが押されても、「決定」ボタンのクリックイベントを発火させて、hoge関数を実行する。


<div class="parent" (keyup.enter)="decide._elementRef.nativeElement.click()">
   // ****
    <button #decide (click)="hoge()">決定</button>
   // ****
</div>

モーダル作る時とかよくあると思います。

4
2
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
2