Can't bind to 'ngIf' since it isn'

2019-06-15 13:07发布

This question already has an answer here:

Just upgraded to Angular 2.1. I have a @input value which I'm attempting to pass an array. As soon as I put *ngIf inside a template I get parse errors? If I print the input value I get: //[object Object],[object Object],[object Object]. Why is this affecting *ngIf?

<div *ngIf="< my value "></div>

-- error zone.js?fad3:388 Unhandled Promise rejection: Template parse errors: Can't bind to 'ngIf' since it isn't a known property of 'div'. ("

1条回答
趁早两清
2楼-- · 2019-06-15 13:37

In your module add

import { CommonModule } from '@angular/common';

@NgModule({
    imports: [
        CommonModule
    ]
})
查看更多
登录 后发表回答