【发布时间】:2017-07-04 20:01:01
【问题描述】:
我的 Angular 2 组件类中有一个名为 myArray 的数组:
@Component({
templateUrl: 'my.component.html'
})
export class MyComponent {
private myArray: Array<string>;
...
}
在 my.component.html 我有一个输入元素:
<input placeholder='write some tags' value=''>
我想要的是将 myArray 的字符串元素插入到输入元素的 value 属性中。字符串应该用逗号分隔。比如:
<input placeholder='write some tags' value='apple, orange, banana'>
我试过了:
<input name='user-tag' placeholder='write some tags' value='*ngFor="let e of myArray"{{e}}'>
但这产生了错误。
我该怎么做?
【问题讨论】:
标签: javascript jquery angular typescript