无法绑定到“*ngIf",因为它不是 angular2 中“td"的已知属性 [英] Can't bind to '*ngIf' since it isn't a known property of 'td' in angular2
本文介绍了无法绑定到“*ngIf",因为它不是 angular2 中“td"的已知属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的 angular 2 应用程序中,我在 ts 文件中点击了偶数,
in my angular 2 application In ts file i have below click even,
ViewPages(Char: string): void {
this.selectedPage = Char;
}
在html中,我尝试在ngif中绑定选择页面
In html, i tried to bind select page in ngif
<td *ngIf="name[0] == {{selectedPage}}">{{name}}</td>
但它抛出"无法绑定到*ngIf",因为它不是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
推荐答案
为此,您应该使用 ng-container.它不会添加到生成的 html 中.
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>
并确保导入 CommonModule.
import { CommonModule } from '@angular/common';
@NgModule({
imports: [
CommonModule
]
})
这篇关于无法绑定到“*ngIf",因为它不是 angular2 中“td"的已知属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文