What is the "tweak" to use/pass a string attribute to a component without using quotes:
I'm always "forced" to use simple quotes inside double quotes like this:
... [anyattribute]="'MyLabel'" ...
I want to use like this:
Using component:
<my-component [anyattribute]="MyLabel"></my-component>
component.ts:
export class MyComponent {
@Input() anyattribute: string;
constructor(){}
}
component.html:
<label> {{anyattribute}} </label>
I've seen some custom components receive parameters on input attributes without the use of double quotes. But don't know what I have to adjust.
Any help?
CodePudding user response:
Just remove the square backets an use it like standard HTML !
<my-component anyattribute="MyLabel"></my-component>