我该怎么做呢?如果值小于9,则显示“月份”,否则显示“月份”。这是我的密码:
<select id="analysis_horizon" class="custom-select form-control" [(ngModel)]="basic_setup.analysis_horizon" formControlName="analysis_horizon" describedby="basic-addon_analysis_horizon">
<option disabled>Select Analysis Horizon</option>
<option *ngIf="'i<=9'" *ngFor="let i of analysis_horizon_array">{{i}} Month</option>
<option *ngIf="'i>9'" *ngFor="let i of analysis_horizon_array">{{i}} Months</option>
</select>这是我得到的错误:
不能对一个元素进行多个模板绑定。只使用一个名为'template‘或前缀为*的属性("isabled>Select analysis_horizon_array]*ngFor=“”let I of analysis_horizon_array“>{i} Month {i} Month 9'”ERROR ->*ngFor=“让我进行分析_horizon_array“>{I}个月;任务: Promise.then;值:错误:模板解析错误:(…)错误:模板解析错误:不能在一个元素上有多个模板绑定。只使用一个名为'template‘或前缀为*的属性("isabled>Select分析地平线]*ngFor=“”let I of analysis_horizon_array“>{i} Month {i} Month’‘”ERROR ->*ngFor="let i analysis_horizon_array“>{i}} Months
发布于 2016-10-19 07:58:22
不能在一个元素上使用多个模板绑定,在本例中是*ngIf和*ngFor。您可以使用插值和三值运算符实现您想要的结果,您不需要使用*ngIf指令:
<select id="analysis_horizon" class="custom-select form-control" [(ngModel)]="basic_setup.analysis_horizon" formControlName="analysis_horizon" describedby="basic-addon_analysis_horizon">
<option disabled>Select Analysis Horizon</option>
<option *ngFor="let i of analysis_horizon_array">
{{i}} {{ i <= 9 ? "Month" : "Months" }}
</option>
</select>https://stackoverflow.com/questions/40125305
复制相似问题