如果内部存在其他问题<;ng模板>;在angular4

如果内部存在其他问题<;ng模板>;在angular4,angular,Angular,如果还有,怎么写 <select #filterBy (change)="someMethod(filterBy.value)> <ng-template [ngIf]="condition; else elsePart"> <option>option1</option> <option>option2</option> </ng-template> <ng-template #elsePart>

如果还有,怎么写

<select #filterBy (change)="someMethod(filterBy.value)>
<ng-template [ngIf]="condition; else elsePart">
 <option>option1</option>
 <option>option2</option>
</ng-template>
<ng-template #elsePart>
 <option>option3</option>
 <option>option4</option>
</ng-template>
</select>
错误:模板分析错误: 绑定表达式不能包含链接表达式

请尝试使用以下方法:

<div *ngIf="condition; then truePart else elsePart"></div>
<ng-template #truePart>
  <select>
    <option>option1</option>
    <option>option2</option>
  </select>
</ng-template>
<ng-template #elsePart>
  <select>
    <option>option3</option>
    <option>option4</option>
  </select>
</ng-template>

选择1
选择2
选择3
选择4
原始答案:


我不认为这是可能的,但是这个链接会帮助你@sudheerKB你可以做同样的事情,但是用
而不是
我认为@sudheerKB我也改变了我的答案@MichaelDeBoey怎么办?可能的重复
<div *ngIf="condition; then truePart else elsePart"></div>
<ng-template #truePart>
  <select>
    <option>option1</option>
    <option>option2</option>
  </select>
</ng-template>
<ng-template #elsePart>
  <select>
    <option>option3</option>
    <option>option4</option>
  </select>
</ng-template>