简体   繁体   中英

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 ):

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

I found this I should import commonModule in app.module.ts. 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

在此处输入图像描述

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM