I have the structural directive in Angular like this
@Directive({ selector: "[access]" })
export class AuthorizationAccessDirective implements OnInit, AfterViewChecked {
constructor(private templateRef: TemplateRef<any>, private eleRef: ElementRef, private viewContainer: ViewContainerRef) {
}
hasView: boolean = false;
@Input("access")
_accessInput: string[];
@Input()
accessFeatures: any;
ngAfterViewChecked() {
this.processAuthorization();
}
ngOnInit() {
this.processAuthorization();
}
}
The HTML using the directive look like this
<li routerLinkActive="active" *access="['CAD']" accessFeatures="{'Settings':31}">
...
</li>
I can get the _accessInput
value, but the extra parameter accessFeatures
is always undefined
in both methods ngOnInit
and ngAfterViewChecked
.
I changed the value to string to simplify, but no successs as well:
<li routerLinkActive="active" *access="['CAD']" accessFeatures="31">
I changed the @Input
definition to @Input("features")
and @Input("accessFeatures")
.
What am I doing wrong?