Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't bind to 'ngIf' since it isn't a known property of 'div' [duplicate]

Tags:

angular

Can't bind to 'ngIf' since it isn't a known property of 'div'.

The element is <div [ngIf]="isAuth" id="sidebar">

And the component is:

import SessionService from '../session/session.service'; import { Component } from '@angular/core';  @Component({   providers: [],   selector: 'navbar-left',   styles: [require('./navbar-left.scss')],   template: require('./navbar-left.html'), }) export default class NavbarLeftComponent {   public isAuth: boolean = false;    constructor(private sessionService: SessionService) {     this.isAuth = sessionService.sessionIsAuth();   } } 

Not sure what exactly I'm doing wrong? This is a child component. In the parent component aka App component the ngIf works fine. Angular RC5

like image 987
Ivaylo Ivanov Avatar asked Aug 20 '16 19:08

Ivaylo Ivanov


People also ask

Can't bind to ngIf since it isn't a known property?

Solution for Angular Can't bind to 'ngIf' since it isn't a known property of 'div' There are multiple ways to fix this. Incorrect ngIf syntax One way, This is due to an error caused due to misspelling capital 'I' for div. To solve this, Import CommonModule or BroswerModule or both into app.

Can't bind to ngFor since it isn't a known property?

ngFor is not a known property would mean for whatever reason, ngFor cannot be recognized in the application. However, the real problem was that ngFor was recognised but the syntax of ngFor was wrong. Anyway, let's hope Angular team improves their logging in future updates.


1 Answers

Just for anyone who still has an issue, I also had an issue where I typed ngif rather than ngIf (notice the capital 'I').

like image 200
dudewad Avatar answered Oct 06 '22 22:10

dudewad