在Angular 4应用程序中,我有一个接受字符串输入的组件:
<app-my-component [myInput]="'some string value'"></app-my-component>
在某些情况下,我需要在字符串中传递一个变量,例如:
<app-my-component [myInput]="'My name is ' + name + '!'"></app-my-component>
如果我能用es6 template literals(又名template strings或back-tick strings)就好了:
<app-my-component [myInput]="`My name is ${name}!`"></app-my-component>
但它不起作用:
未捕获错误:模板分析错误:
正确的方法是什么?