如何在从服务器获取数据后加载页面时检查选项?
<ion-select [(ngModel)]="interests" multiple="true" (ionChange)="addInterests(interests)">
<ion-option>Automobile</ion-option>
<ion-option>Cellphones</ion-option>
<ion-option>Toys</ion-option>
</ion-select>
所以在你的打字稿文件中你会有这样的东西:
private interests: Array<string>;
private interestReceivedFromServer: string;
在您的HTML中,您可以这样做:
<ion-select multiple="true">
<ion-option *ngFor="let interest of interests" value="{{interest}}" [selected]="interest == interestReceivedFromServer">
{{ interest }}
</ion-option>
</ion-select>
这样会很好。