priyanka.sarkar priyanka.sarkar - 1 year ago 78
Javascript Question

Iterated names are not displaying using ngFor in angular2

I am new to Angular2. I wanted to display the list of items . In my first-angular-js-2-application.js file I have done as under

import {Component, View} from 'angular2/core';

selector: 'first-angular-js-2-application'

templateUrl: 'first-angular-js-2-application.html'

export class FirstAngularJs2Application {

constructor() {'FirstAngularJs2Application Component Mounted Successfully');

public products = [
{name: "Butter"},
{name: "Milk"},
{name: "Yogurt"},
{name: "Cheese"},

and in first-angular-js-2-application.html I have

<h1><b><font color="blue">Product names</font></b></h1>
<li *ngFor="#p of products" >
{{ }}

Now when I run the application, it is not displaying the product names.

What wrong I am making?

N.B.~ I have generated Angular2 application through Yoeman

Answer Source

try this

<li *ngFor="let p of products" >
                  {{ }}

I have created a plnkr but it is final version of angular2

Plunker Demo

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download