イベントバインディング処理内でのカスタム属性(data-*)へのアクセス方法
target.dataset
内に格納されるので以下でアクセス
sample.component.html
<a data-xxx="カスタムデータ" (click)="onClick($event)">sample</a>
sample.component.ts
onClick(event) {
console.log(event.target.dataset.xxx);
}
More than 5 years have passed since last update.
イベントバインディング処理内でのカスタム属性(data-*)へのアクセス方法
target.dataset
内に格納されるので以下でアクセス
<a data-xxx="カスタムデータ" (click)="onClick($event)">sample</a>
onClick(event) {
console.log(event.target.dataset.xxx);
}
Register as a new user and use Qiita more conveniently