简体   繁体   English

NG0303:无法绑定到“ngif”,因为它不是“div”的已知属性

[英]NG0303: Can't bind to 'ngif' since it isn't a known property of 'div'

I try to learn Angular with documentation but I have an error but this code work (I learn with this tutorial https://angular.io/tutorial/toh-pt4 ):我尝试使用文档学习 Angular 但我有一个错误但此代码有效(我通过本教程学习https://angular.io/tutorial/toh-pt4 ):

NG0303: Can't bind to 'ngif' since it isn't a known property of 'div'. NG0303:无法绑定到“ngif”,因为它不是“div”的已知属性。

I found this I should import commonModule in app.module.ts.我发现我应该在 app.module.ts 中导入 commonModule。 But it doesn't work.但它不起作用。 Why?为什么? Do, you think that learning with offical documentation is good idea?你认为通过官方文档学习是个好主意吗?

Please use the format like this:请使用如下格式:

    <div *ngIf="condition; else elseBlock">
    Content to render when condition is true.
    </div> 
    <ng-template #elseBlock>Content to render when condition is false.
    </ng-template>

Common module is common for all modules.通用模块对所有模块都是通用的。 if you are using lazy loaded modules then it must contains the CommonModule as well如果您使用的是延迟加载模块,那么它也必须包含 CommonModule

在此处输入图像描述

Me paso algo similar lo que me faltaba era agregar el componente en declarations de modulo del componente Me paso algo similar lo que me faltaba era agregar el componente en declarations de modulo del componente

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 NG0303:无法绑定到“ngbTooltip”,因为它不是“button”的已知属性 - NG0303: Can't bind to 'ngbTooltip' since it isn't a known property of 'button' 在控制台中出现错误无法绑定到“ngif”,因为它不是 angular 应用程序中“div”的已知属性 - Getting error in console Can't bind to 'ngif' since it isn't a known property of 'div' in angular app core.js:12853 无法绑定到“ngIf”,因为它不是“div”的已知属性 - core.js:12853 Can't bind to 'ngIf' since it isn't a known property of 'div' 无法绑定到“ useStickyClasses”,因为它不是“ div”的已知属性 - Can't bind to 'useStickyClasses' since it isn't a known property of 'div' 无法绑定 'ngIf' 它不是 'button' 的已知属性 - Can't bind 'ngIf' it isn't a known property of 'button' NG2-Charts模板解析错误:无法绑定到“数据集”,因为它不是“ canvas”的已知属性 - NG2-Charts Template parse errors: Can't bind to 'datasets' since it isn't a known property of 'canvas' NG2-Charts 无法绑定到“数据集”,因为它不是“画布”的已知属性 - NG2-Charts Can't bind to 'datasets' since it isn't a known property of 'canvas' 带有 Angular 的 NG2 图表:无法绑定到“颜色”,因为它不是 Angular 中“画布”的已知属性 13 - NG2 Chart with Angular: Can't bind to 'colors' since it isn't a known property of 'canvas' in Angular 13 无法绑定到&#39;ngSwitchDefault&#39;,因为它不是&#39;ng-template&#39;的已知属性 - Can't bind to 'ngSwitchDefault' since it isn't a known property of 'ng-template' 具有Angular 4的ng2-chart:无法绑定到“数据”,因为它不是“ canvas”的已知属性 - ng2-chart with Angular 4: Can't bind to 'data' since it isn't a known property of 'canvas'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM