簡體   English   中英

在angular2中使用ngFor不會顯示迭代名稱

[英]Iterated names are not displaying using ngFor in angular2

我是Angular2的新手。 我想顯示物品清單。 在我的first-angular-js-2-application.js文件中,我已經完成了

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

@Component({
  selector: 'first-angular-js-2-application'
})

@View({
  templateUrl: 'first-angular-js-2-application.html'
})

export class FirstAngularJs2Application {

  constructor() {
    console.info('FirstAngularJs2Application Component Mounted Successfully');

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

first-angular-js-2-application.html中,

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

現在,當我運行該應用程序時,它沒有顯示產品名稱。

我在做什么錯?

NB〜我已經通過Yoeman生成了Angular2應用程序

嘗試這個

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

我創建了一個plnkr,但它是angular2的最終版本

柱塞演示

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM