<ng-template pTemplate="body"
let-node="rowData">
<button type="button"
[disabled]="hasValid(node)"
*ngIf="getBtnLabel(node)"
class="btn btn-default btn-sm"
[attr.data-v]="rAddBtn(node)"
translate>
<i class="s s-plus"
aria-hidden="true"></i> {{getBtnLabel(node)}}
</button>
</ng-template>
но я не могу получить атрибут "data-v" через директиву, которую я создал.Код работает нормально, если он находится внутри блока "div" вместо ng-template.Ниже моя директива, которую я сделал
import {
Directive,
ElementRef,
OnInit,
} from '@angular/core';
@Directive({
// tslint:disable-next-line
selector: '[data-v]'
})
export class DataVandvDirective implements OnInit {
vAttribute: string;
constructor(private element: ElementRef) {
const native = this.element.nativeElement;
this.vAttribute = native.getAttribute('data-v');
console.log("the v att", this.vAttribute);
}
ngOnInit(): void { }
}