我想在html中添加一个动态html属性到我的child组件,比如hits:
<child-component test={{ variable }}></child.component>
我不想使用它作为输入,只是需要它在html中进行测试. 我try 了上面的方法,但当我这样做时,我得到了一个错误:
"Can't bind to 'test' since it isn't a known property"
对此有好的解决方案吗?
Thx!
我想在html中添加一个动态html属性到我的child组件,比如hits:
<child-component test={{ variable }}></child.component>
我不想使用它作为输入,只是需要它在html中进行测试. 我try 了上面的方法,但当我这样做时,我得到了一个错误:
"Can't bind to 'test' since it isn't a known property"
对此有好的解决方案吗?
Thx!
您可以使用attr
来创建一个属性!
<child-component [attr.test]="variable"></child.component>