Tuesday, June 6, 2017

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

The usage of *ngFor within the li or div element has changed .like an example given below states that #contact of contacts where #contact defines as local variable.

<li *ngFor="#contact of contacts"></li>

Instead of using #contact,kindly replace your code snippet with the following structure in order to declare local variables inside of structural directives.

<li *ngFor="let contact of contacts"

(click)="onSelect(contact)"

[class.clicked]="showDetail === true">

{{contact.firstName}} {{contact.lastName}}

</li>

Hope it will help you someDay.

Twitter @dotnetpiper

Can't bind to 'ngModel' since it isn't a known property of 'input'

This error may occur at your end during the Angular2 development, specially during creation of two way binding using [(ngModel)] with your Input type.

To fix this error kindly use the following in app.module.js and import the namespace like given below:

import { FormsModule } from '@angular/forms';

@NgModule({

declarations: [

AppComponent,

FirstComponent

],

imports: [

BrowserModule,FormsModule

],

providers: [],

bootstrap: [AppComponent]

})

As soon as you add this into the above given file.it should start work as anticipated.