当在Angular Web组件中使用*ngIf指令时遇到错误,通常是由于以下原因之一:
显示组件内容
export class MyComponent {
showComponent: boolean = true;
}
export class MyComponent implements OnInit {
showComponent: boolean;
ngOnInit() {
this.showComponent = true;
}
}
import { CommonModule } from '@angular/common';
@NgModule({
imports: [
CommonModule
]
})
export class MyModule { }
显示组件内容
显示组件内容
通过检查以上问题,并根据需要进行调整,您应该能够解决*ngIf指令错误。