mam ten angular2 szablonu:angular2 Nie można mieć wiele powiązań szablonów na jednym elemencie
<template *ngIf="alerts.length > 0">
<alert *ngFor="let alert of alerts;let i = index" [type]="alert.type" dismissible="true" (close)="closeAlert(i)">
{{ alert?.msg }}
</alert>
</template>
otrzymuję te błędy:
zone.js:461 Unhandled Promise rejection: Template parse errors:
Can't have multiple template bindings on one element. Use only one attribute named 'template' or prefixed with * (" </div>
<div *ngSwitchCase="false" class="container p-t-10">
<alert *ngIf="alerts.length > 0" [ERROR ->]*ngFor="let alert of alerts;let i = index" [type]="alert.type" dismissible="true" (close)="closeAlert"): [email protected]:37
czym problem kładę * ngIf i * ngFor w różne elementy html. Powinno działać. Nie?
oraz:
Can't bind to 'type' since it isn't a known property of 'alert'. (""container p-t-10">
<alert *ngIf="alerts.length > 0" *ngFor="let alert of alerts;let i = index" [ERROR ->][type]="alert.type" dismissible="true" (close)="closeAlert(i)">
{{ alert?.msg }}
</alert>
"): [email protected]:80
dodałem
*ngIf="alerts.length > 0
aby uniknąć przypadków alert = []
. Jak mogę to naprawić inaczej?
spróbuj 'attr.type' zamiast typu prostego –