HostAttributeToken
Creates a token that can be used to inject static attributes of the host node.
class HostAttributeToken {
constructor(attributeName: string)
toString(): string
}
Constructor
Methods
toString() |
---|
ParametersThere are no parameters. Returns
|
Usage notes
Injecting an attribute that is known to exist
@Directive()
class MyDir {
attr: string = inject(new HostAttributeToken('some-attr'));
}
Optionally injecting an attribute
@Directive()
class MyDir {
attr: string | null = inject(new HostAttributeToken('some-attr'), {optional: true});
}