I am passing an attribute into my Angular component in the form of:
<my-component myAttribute></my-component>
In order to change a variable within the component that determines the CSS for width & height.
I also have pre-defined attribute values established such that inputting:
<my-component large>
Will set the width and height variables to equal 100 (100px after processing).
However, I am curious as to whether I can write multiple @Input() criteria in a way that I will not have lots of separate @Input()s, perhaps using a switch statement that will do the same job?
I have attempted this a little, but only received a sea of red squigglies under the code.
my inputs
size = 50 // Default value
@Input('small') set small(value) {
this.size = !value ? 25 : this.size;
}
@Input('medium') set medium(value) {
this.size = !value ? 50 : this.size;
}
@Input('large') set large(value) {
this.size = !value ? 100 : this.size;
}
@Input('x-large') set xlarge(value) {
this.size = !value ? 200 : this.size;
}