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

I think it's: let item of Products not for in the productSearch.component.html file. Check the documentation


    var p1 = new Product();   //<----added ();
    p1.name = "alkan";

    var p2 = new Product();   //<----added ();
    p2.name = "alper";
    this.Products = [p1, p2];

     //<---replace for keyword by of keyword
    <li *ngFor="let item of Products">{{item.name}}</li>   

Update

You also need to add CommonModule as shown below,

import {NgModule} from '@angular/core';   
import {ProductSearchComponent} from './productSearch.component'

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

@NgModule({
    imports: [CommonModule],                   //<====added
    exports: [ProductSearchComponent],
    declarations: [ProductSearchComponent],

})

Tags:

Angular