1

我能够列出并添加选择选项,如下所示:

   <select class="form-control" [(ngModel)]="feed.feed_store" name="feed_store" placeholder="Select Store">
      <option *ngFor="let feedstore of feedstores" [value]="feedstore">{{ feedstore }}</option>
    </select>

现在在我的编辑表单中,我想显示数据库中的选定选项。不确定

4

2 回答 2

0

您可以selected根据以下条件将属性设置为选项:{{ feedstore }}

于 2018-02-08T22:09:44.927 回答
0

您可以selected根据如下条件将属性设置为选项:

<ng-container *ngIf="feed">
    <select class="form-control" [(ngModel)]="feed.feed_store" name="feed_store" placeholder="Select Store">
          <option *ngFor="let feedstore of feedstores" 
                 [value]="feedstore"
                 [selected]="feedstore === 'feedstore_from_database'">
              {{ feedstore }}
          </option>
    </select>
<ng-container>
于 2018-03-10T10:16:06.637 回答