如何在选择div时设置选择框的值。我在这里使用ngModel,但它无法正常工作。
这是我的样本。
somecomponent.html
<div class="form-group input-holder">
<label class="col-lg-2">Storage type</label>
<div class="col-lg-4">
<select class="category" name="storagetype" [(ngModel)]="storageType">
<option *ngFor="let value of values" [value]="value">{{ value }}</option>
</select>
</div>
</div>
somecomponent.html
ngOnInit() {
this.storageId = this.storageEntryService.storages.slice();
this.subscription = this.storageEntryService.StartEditStorage.subscribe(
(index: number) => {
this.storageIdIndex = index;
this.editedstorage = this.storageEntryService.getStorage(index);
this.storageForm.setValue({
storagetype: this.editedstorage.storagetype.toUpperCase()
})
}
); }
然后
<!-- modal -->
<div class="md-modal md-effect-1" id="modal-1" [ngStyle]="{'visibility': showmodal === true ? 'visible' : 'hidden'}">
<div class="md-content" [ngClass]="{'showmodalcss': showmodal === true}">
<h3>Select Storage</h3>
<div>
<table class="table responsive table-striped">
<thead class="bg-primary">
<tr>
<th>Storage ID</th>
<th>Storage Type</th>
<th>Lock</th>
<th>Created By</th>
<th>Created date</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let storages of storageId; let i = index" (click)="editItem(i)">
<td>{{ storages.id }}</td>
<td>{{ storages.storagetype }}</td>
<td>{{ storages.islock }}</td>
<td>{{ storages.createdby }}</td>
<td>{{ storages.createddate }}</td>
</tr>
</tbody>
</table>
<button class="md-close" (click)="showmodal = false">Close me!</button>
</div>
</div>
</div>
我想要的是每次点击一些storageid必须显示select的值。第二张图像显示,每次选择某个存储ID时,它都不会传递数据。