Angular 添加单引号和变量到 component.html 不读取变量和引号
Angular adding single quotes and variable to the component.html not reading the variable and quotes
我正在使用 Angular 13,在我的 component.html 中我有这个:
这一行有效:
<highcharts-chart [constructorType]="'stockChart'"></highcharts-chart>
现在,当我有一个变量时:
myvalue = 'stockChart';
然后这样做:
<highcharts-chart [constructorType]="myvalue"></highcharts-chart>
或
<highcharts-chart [constructorType]="'myvalue'"></highcharts-chart>
或
<highcharts-chart [constructorType]="{{myvalue}}"></highcharts-chart>
以上 3 个不起作用,但第一个起作用。
如何使用变量让它工作?
您可以尝试在 component.ts 中转义字符并在 html
中绑定该值
我正在使用 Angular 13,在我的 component.html 中我有这个:
这一行有效:
<highcharts-chart [constructorType]="'stockChart'"></highcharts-chart>
现在,当我有一个变量时:
myvalue = 'stockChart';
然后这样做:
<highcharts-chart [constructorType]="myvalue"></highcharts-chart>
或
<highcharts-chart [constructorType]="'myvalue'"></highcharts-chart>
或
<highcharts-chart [constructorType]="{{myvalue}}"></highcharts-chart>
以上 3 个不起作用,但第一个起作用。
如何使用变量让它工作?
您可以尝试在 component.ts 中转义字符并在 html
中绑定该值