I have codes like bellow
@Component({
selector: 'app-name',
template: `{{ name }}`
})
export class NameComponent {
@Input() name: string;
}
@Component({
selector: 'app-parent',
template: `
<!--Option 1-->
<app-name name="{{ name }}"></app-name>
<!--Option 2-->
<app-name [name]="name"></app-name>
`
})
export class ParentComponent {
name = 'parent';
}
as you can see I have two different ways to bind the input name in app-name
such name = {{ xxx }} and [name]=xxx
as following
<app-name name="{{ name }}"></app-name>
<app-name [name]="name"></app-name>
My question is, which one would be preferred? Are there any pros and cons? Do I need to worry about this?
Thank you in advance