有什么方法可以将ngModel值绑定到ionic中的select-searchable选项中,以查看localStorage的默认值。
<ion-col col-6>
<select-searchable okText="Odaberi" cancelText="Otkaži"
class="inputStyle"
item-content
[(ngModel)]="WarrentItem.deviceManufacturerId"
searchFailText="Nema rezultata"
[items]="allManufacturers"
itemValueField="id"
itemTextField="value"
[canSearch]="true"
(ionClear)="onClear($event)"
(onChange)="materialChanged2($event)">
</select-searchable>
</ion-col>
在这种情况下,我在选项中列出了所有制造商的清单,但是我需要获取在打开此表单时在localStorage中设置的默认值。
答案 0 :(得分:0)
您可以这样设置
<ion-item>
<ion-label>Port</ion-label>
<select-searchable
item-content
[(ngModel)]="port"
[items]="ports"
itemValueField="id"
itemTextField="name"
[canSearch]="true"
(onChange)="portChange($event)">
</select-searchable>
</ion-item>
ports = [
{ id: 1, name: 'Tokai' },
{ id: 2, name: 'Vladivostok' },
{ id: 3, name: 'Navlakhi' }
];
port = {
id: 3,
name: 'Navlakhi'
};