如何将列表从 angular 4 组件传递到 html

How do I pass a list from an angular 4 component to html

我正在使用 angular 4,我想将列表传递给 html。 在angular 4中,我的组件是:

a = ["abc", "xyz", "lmn"]

html 方面: <input type="text" data-provide="typeahead" data-source='["abc","xyz","lmn"]' placeholder="item..." class="form-control" />

我必须在数据源中传递列表,它是一个 Bootstrap-3-Typeahead js 对象。

如何将它与 angular 4

一起使用

您可以使用 attr 关键字

将任何 attribute 与组件 variable 绑定
<input type="text" data-provide="typeahead" [attr.data-source]="a" placeholder="item..." class="form-control" />