#Dynamically apply attributes?

8 messages · Page 1 of 1 (latest)

valid juniper
#

In my scenario, I’m basically creating a component around another component, and that inner component has attributes that govern its behavior; I’m hoping there’s a way that my outer component can decide which attributes to apply to the inner one, declaratively or programmatically, but from what I’m reading this may not be a supported thing?

naive egret
#

You should clarify what you mean, with a concrete example, because inputs are meant to be passed to components, and of course other components do that, and inputs can of course have a dynamic value, so I'm not sure what you're asking.

valid juniper
#

Specifically, it’s a kendo control where different types of grouping behavior are determined not by an input but from the existence of specific attributes

#

Like single-token directives? I don’t know what they’re called exactly

naive egret
#

You should clarify what you mean, with a concrete example. Don't leave us in the dark. If you're thinking about a kendo control with specific attributes, share the link to the documentation/code of that kendo control and of those specific attributes.

valid juniper
#

“kendoMultiSelectTreeExpandable” in that example would be one of them, but there are several

wicked vine
#

What you are referring to are attribute directives https://angular.io/guide/attribute-directives

I don't believe you can conditionally apply directives so you may have to try an approach that uses ngTemplates + some structural directives.

https://stackoverflow.com/a/47725361
https://angular.io/api/common/NgTemplateOutlet