[英]Can't bind to 'ngSwitchDefault' since it isn't a known property of 'ng-template'
I get the error: 我收到错误:
Can't bind to 'ngSwitchDefault' since it isn't a known property of 'ng-template' 无法绑定到'ngSwitchDefault',因为它不是'ng-template'的已知属性
Before I go on: this is not a duplicate of Angular2 - "Can't bind to 'ngSwitchWhen' since it isn't a known property of 'template'." 在我继续之前:这不是 Angular2的重复- “无法绑定到'ngSwitchWhen',因为它不是'模板'的已知属性。”
The ngSwitchWhen binds perfectly nice just the way that I used it. ngSwitchWhen绑定非常好,就像我使用它的方式一样。 The problem is with the ngSwitchDefault, which I can only use in it's sytactic suggared verison *ngSwitchDefault . 问题在于ngSwitchDefault,我只能使用它的sytactic suggared verison * ngSwitchDefault 。 But since I have another structural directive on the matter ( *ngIf ) I would like to use the "Template-[ngSwitchDefault]"-Version, which gives me the aforementioned error. 但由于我对此事有另一个结构性指令( * ngIf ),我想使用“Template- [ngSwitchDefault]” - Version,它给出了上述错误。
Question: Any reason why I can use [ngSwitchCase], but not [ngSwitchDefault] ? 问题:我可以使用[ngSwitchCase]而不是[ngSwitchDefault]的任何原因?
<div>
<div *ngFor="let field of fields">
<ng-container [ngSwitch]="field.myType">
<ng-template [ngSwitchCase]="'something'">
<div *ngIf="fieldIsVisibile[field.name]">
Somthing special: {{field.name}}
</div>
</ng-template>
<ng-template [ngSwitchDefault]>
<div *ngIf="fieldIsVisibile[field.name]">
Regular: {{field.name}}
</div>
</ng-template>
</ng-container>
</div>
</div>
I think it should just be 我认为它应该是
<ng-template ngSwitchDefault>
because ngSwitchDefault
doesn't get a value passed and doesn't have an @Input()
因为ngSwitchDefault
没有传递值并且没有@Input()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.