私は修正できないような論理エラーがありますが、リテラルロジックエラーを除いて、なぜAngularはこれをやりませんか?ngSwitchの条件付きボタンとngFor with async piped array
私はジェンダーをdrop.Nameでドロップダウンしていますが、レンダリング時に[オブジェクトオブジェクト]がドロップダウンに表示されるだけです。
着信コード:
<drop-down [Content]="GenderTxt" [AriaLabel]="'Gender Select'" [Type]="'Gender'" [Options]="(MenuOptions | async)?.Genders"
(Click)="SetGender($event)">
</drop-down>
エラーメッセージ:
Can't have multiple template bindings on one element. Use only one attribute named 'template' or prefixed with * ("aria-labelledby="{{AriaLabel}}">
<div [ngSwitch]="Type">
<button *ngSwitchCase="Gender" [ERROR ->]*ngFor="let drop of Options" class="dropdown-item FakeClickable" (click)="Clicked(drop)">{{drop.Name}"): ng:///AppModule/[email protected]:37
Can't have multiple template bindings on one element. Use only one attribute named 'template' or prefixed with * ("-item FakeClickable" (click)="Clicked(drop)">{{drop.Name}}</button>
<button *ngSwitchDefault [ERROR ->]*ngFor="let drop of Options" class="dropdown-item FakeClickable" (click)="Clicked(drop)">{{drop}}</bu"): ng:///AppModule/[email protected]:31
コード:基本的に私は外側のレベルにスイッチケースを上に移動する必要が私の問題は
<div class="dropdown-menu" attr.aria-labelledby="{{AriaLabel}}" [ngSwitch]="Type">
<button *ngSwitchCase="Gender" *ngFor="let drop of Options" class="dropdown-item FakeClickable" (click)="Clicked(drop)">{{drop.Name}}</button>
<button *ngSwitchDefault *ngFor="let drop of Options" class="dropdown-item FakeClickable" (click)="Clicked(drop)">{{drop}}</button>
</div>
ですdivを作成し、各ボタンに対して新しいdivを作成しますか?
の可能性のある重複した[angular2 RC4に一つの要素に複数のテンプレートバインディングを適用する方法](https://stackoverflow.com/questions/38585720/how-to-apply-multiple-template- bindings-on-one-angular-2-rc4) –