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'))
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With