Issue
I want to create a structural directive that queries all anchors that has "routerLink" directive in the app and and access the value of the routerLink.
I tried to implement it with this way but without success:
@Directive({
selector: '[appShowByRole], a[routerLink]'
})
export class ShowByRoleDirective implements OnInit{
constructor(
private readonly elmRef: ElementRef,
@Optional() @Inject(forwardRef(() => RouterLink)) private routerLink: RouterLink,
) {
}
ngOnInit(): void {
if (this.routerLink) {
debugger;
}
}
}
Solution
You can use Input
to receive any attribute from template.
@Directive({
selector: '[appShowByRole], a[routerLink]'
})
export class ShowByRoleDirective implements OnInit {
@Input('routerLink') link: any;
....
}
Answered By - paranaaan
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.