如何将字符串值传递给 angular2 中的组件 [英] How to pass a string value to a component in angular2
本文介绍了如何将字符串值传递给 angular2 中的组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将字符串值传递给 angular2 中的组件,但它不适用于默认绑定.我在想类似的事情:
I'd like to pass a string value to a component in angular2, but it doesn't work with the default binding. I'm thinking of something similar to this:
<component [inputField]="string"></component>
不幸的是,赋值的右侧只允许使用表达式.有没有办法做到这一点?
Unfortunately, only expressions are allowed on the right side of the assignment. Is there a way to do this?
推荐答案
字符串文字可以通过不同的方式传递:
String literals can be passed in different ways:
<component inputField="string"></component>
<component [inputField]="'string'"></component>
<component inputField="{{'string'}}"></component>
这篇关于如何将字符串值传递给 angular2 中的组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文