无法绑定到"* 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>
但由于它不是'td'的已知属性,因此抛出了"无法绑定到'* ngIf'.
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屋!
查看全文