I get the error:
Can't bind to 'ngSwitchDefault' since it isn't a known property of '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'."
The ngSwitchWhen binds perfectly nice just the way that I used it. The problem is with the ngSwitchDefault, which I can only use in it's 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.
Question: Any reason why I can use [ngSwitchCase], but not [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()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With