【发布时间】:2018-07-19 13:39:39
【问题描述】:
我不知道如何用角度来写我的条件,我找不到一个等价的例子。
我怎样才能听到我的材料选择?
我如何写一个 ngIf 条件?
{{referentielToDisplay.speSS}} 的值与我的 toppingList 之一相同,我想写:
如果ReferentielToDisplay。 speSS 等于在材料选择中选择的项目所以:显示此卡
*ngIf="referentielToDisplay.speSS === topping"
组件.html
<mat-form-field style="width:100%" appearance="outline">
<mat-label>Sélectionner une spécialité</mat-label>
<mat-select placeholder="Toppings" [formControl]="toppings" multiple="true" >
<mat-option *ngFor="let topping of toppingList" [value]="topping" >{{topping}}</mat-option>
</mat-select>
</mat-form-field>
<div *ngFor="let referentielToDisplay of referentielsToDisplay | async" >
<mat-card *ngIf="referentielToDisplay.speSS === topping">
{{referentielToDisplay.nomSS}}
</mat-card>
</div>
组件.ts
toppings = new FormControl( );
toppingList: string[] = ['Multi-spécialité','Hématologie', 'Neurologie', 'Urologie', 'Digestif', 'Endocrinologie', 'Pneumologie', 'ORL','Dermatologie', 'Sein-Gynecologie'];
【问题讨论】:
-
不清楚。什么是“我的数据”?什么是“我的桌子”?
toppingdefined 在哪里?您是在问如何测试 toppingList 是否包含 referentielToDisplay.speSS?看数组的文档:developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/… -
在您比较超出范围的
和 中不是“顶部”吗?检查“顶部”的可见性我怎样才能听到我的垫子选择的顶部?
标签: angular angular-material2 angular-ng-if