Angular 如何将选定项目的文本绑定到

Angular 如何将选定项目的文本绑定到,angular,Angular,我知道如何在AngularJS中做到这一点,但我发现在Angular4.x中很难做到 我有这个 <select id="taxTypeId" name="taxTypeId" [(ngModel)]="tax.taxType" class="form-control"> <option *ngFor="let tt of taxTypes" value={{tt.id}}>{{tt.name}}</option> </select> {{ta

我知道如何在AngularJS中做到这一点,但我发现在Angular4.x中很难做到

我有这个

<select id="taxTypeId" name="taxTypeId" [(ngModel)]="tax.taxType" class="form-control">
   <option *ngFor="let tt of taxTypes" value={{tt.id}}>{{tt.name}}</option>
</select>
{{tax.taxType.name}}

{{tt.name}
{{tax.taxType.name}

我想为所选的任何值绑定所选文本(name属性)。请帮忙。

我仍然不确定我是否完全理解这个问题。还不清楚
tax
taxType
的确切外观,但这可能会满足您的需要:

<select id="taxTypeId" name="taxTypeId" [(ngModel)]="tax.taxType" class="form-control">
   <option *ngFor="let tt of taxTypes" [ngValue]="tt.taxType">{{tt.name}}</option>
</select>
{{tax.taxType?.name}}

{{tt.name}
{{tax.taxType?.name}

(使用
ngValue
而不是
value
,并且
之前的
可能不是必需的。名称
只是为了防止在未选择任何内容时出错)

我仍然不确定是否完全理解该问题。还不清楚
tax
taxType
的确切外观,但这可能会满足您的需要:

<select id="taxTypeId" name="taxTypeId" [(ngModel)]="tax.taxType" class="form-control">
   <option *ngFor="let tt of taxTypes" [ngValue]="tt.taxType">{{tt.name}}</option>
</select>
{{tax.taxType?.name}}

{{tt.name}
{{tax.taxType?.name}

(使用
ngValue
而不是
value
,并且
之前的
可能不是必需的。名称
只是为了防止在未选择任何内容时出错)

我发现问题不清楚。所选项目将是
tt.id
tax.taxType
相同的项目。这就是我要做的。从下拉列表中选择项目时,我希望所选文本显示在下拉列表下方。我希望你现在能理解我发现这个问题不清楚。所选项目将是
tt.id
tax.taxType
相同的项目。这就是我要做的。从下拉列表中选择项目时,我希望所选文本显示在下拉列表下方。我希望你现在明白了