I have issue with getting data from HTML data attr to component.
In Template I have:
<button [attr.data-direction]="next" type="text" (click)="nextNotes()" [disabled]="checkPage(paginator)"> > </button>
And how can I call this data attr in class method after click? There is some ng workflow for that or purejs?
console.log(data)
Not sure if I am 100 % capish here, but if you just want the value from data-directive
, then you could pass the button as a local variable to nextNotes()
and retrieve the value from there using getAttribute
Template:
<button #btn data-direction="next" type="text" (click)="nextNotes(btn)" [disabled]="checkPage(paginator)"></button>
Class method:
nextNotes(val) {
console.log(val.getAttribute('data-direction'))
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.