0
我有一個服務的提取關鍵字,我用ngFor來顯示這些關鍵字作爲標籤。但我得到這個上面的錯誤找不到類型爲'object'的不同支持對象'[object Object]'。 NgFor只支持綁定到Iterables如陣列離子2
這裏是代碼
<ion-content>
<ion-searchbar [(ngModel)]="myInput" [showCancelButton]="shouldShowCancel" (ionInput)="onInput($event)" (ionCancel)="onCancel($event)">
</ion-searchbar>
<ion-card *ngIf="suggest">
<ion-card-header>
Suggestions
</ion-card-header>
<ion-card-content>
<ion-badge *ngFor="let item of keyword;" > {{item.keyword}}</ion-badge>
</ion-card-content>
這是我打電話的時候,
onInput(event) {
this.suggest = true;
this.keywords = this.logins.getkeywords(this.myInput).subscribe((data) => this.keywords = data)
}
,這裏是該服務的搜索服務
}
這裏是服務器響應
[{"keyword":"asd"},{"keyword":"aptitude"},{"keyword":"arrangements"},{"keyword":"averages"},{"keyword":"aadasda"},{"keyword":"asdasd"},{"keyword":"anesthesiology"},{"keyword":"asds"}]