问题
in my angular 2 application In ts file i have below click even,
ViewPages(Char: string): void {
this.selectedPage = Char;
}
In html, i tried to bind select page in ngif
<td *ngIf="name[0] == {{selectedPage}}">{{name}}</td>
but it is throwing the ""Can't bind to '*ngIf' since it isn't a known property of 'td'.
it will be grt help if someone help me regarding this
回答1:
You should use ng-container for this. It isn't added to resulting html.
<ng-container *ngIf="name[0] == {{selectedPage}}">
<td>{{ name }}</td>
</ng-container>
And make sure, that CommonModule is imported.
import { CommonModule } from '@angular/common';
@NgModule({
imports: [
CommonModule
]
})
来源:https://stackoverflow.com/questions/45436552/cant-bind-to-ngif-since-it-isnt-a-known-property-of-td-in-angular2