不评估不带括号的自定义组件属性中的插值

时间:2017-02-07 08:39:13

标签: angular

This manual说以下内容:

  

我们经常在插值和属性绑定之间进行选择。该   以下绑定对执行相同的操作:

<p><img src="{{heroImageUrl}}"> is the <i>interpolated</i> image.</p>
<p><img [src]="heroImageUrl"> is the <i>property bound</i> image.</p>

但是,我尝试使用我的自定义组件并且没有{{heroImageUrl}}进行评估:

@Component({
    selector: 'custom',
    inputs: ['heading'],

并像这样使用:

<custom heading="{{tasksHeading}}"...

但它没有评估表达式,我得到'{{tasksHeading}}'字符串。这按预期工作:

<custom [heading]="tasksHeading"...

为什么插值属性的第一个选项不像文档中显示的那样工作?

0 个答案:

没有答案