【发布时间】:2026-01-12 11:30:01
【问题描述】:
错误
支持“string”类型的对象“活动”。 NgFor 只支持绑定到数组等Iterables。
我试图让它每次单击切换时都会将{{ setting }} 从非活动更改为活动。如果另一种方法不可行,则试图使此方法起作用。
代码html:
<ion-item>
<ion-label>Front Door</ion-label>
<ion-toggle [(ngModel)]="fdoor" ng-model="ni_toggle" (ionChange)="Fdoor()" (click)="change()"></ion-toggle>
</ion-item>
<div *ngFor="let setting of sett">
{{ setting }}
</div>
ts:
active: string = "Active"
inactive: string = "Inactive"
change() {
if(this.fdoor = true) {
this.sett = this.active
}
}
【问题讨论】:
标签: arrays string ngfor ionic4