Can't bind to '*ngIf' since it isn't a known property of 'td' in angular2

吃可爱长大的小学妹 提交于 2021-02-08 06:44:24

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!