私はこのパッケージを使用していますhttps://www.npmjs.com/package/angular2-mentions。 はので、私のコードはこれです:角2の言及:APIコールの後に配列のバインドをディレクティブに更新する方法
.ts file :
ngOnInit():void {
this.items.push("temp Name")
let __this = this
this._userService.getAll(1).subscribe(res => {
res.users.forEach(function (a,b) {
__this.items.push(a)
})
console.log(__this.items)
})
}
の.htmlファイル:
<input type="text" [mention]="items" >
配列が更新され、APIからデータを持っていますが、ディレクティブ[言及]が古い配列に結合しているされている値が含まれています開始時に静的に初期化されています。
答えが分かりましたか? – krzysztofla