Dustin Silk
Dustin Silk

Reputation: 4610

Add component Input() with dot notation options: attr.src, style.padding.px

I see a lot of Angular directives have dot notation options:

style.padding.px
style.padding.%
attr.src

And some libraries like flex-layout use it for different responsive sizes:

fxLayout.gt-sm
fxAlign.sm

Is it possible to do this with a component @Input?

If not, how are these other guys doing it? Or are they creating a new input for each possible name:

@Input('style.padding.px') paddingPx
@Input('style.padding.%') paddingPercent
...

EDIT

My use case:

I want to be able to 'catch all' or dynamically add more @Input()'s.

So say I have a @Input('size') option.. I'd like to be able to add size.sm, size.md ect which in this case would be pulled from flex-layouts custom breakpoints

Upvotes: 2

Views: 338

Answers (1)

Oleksii Didenko
Oleksii Didenko

Reputation: 69

The only option is to create an @Input() for each possible parameter

You can see how it is implemented in flex-layout, for example

Upvotes: 1

Related Questions