这是我的代码angular2 ngFor不显示数据
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-jobcompleted',
templateUrl: './jobcompleted.component.html',
styleUrls: ['./jobcompleted.component.scss']
})
export class JobcompletedComponent {
name: string;
email: string
address: string;
hobbies: string[];
showHobbies: boolean;
constructor(){
this.name = "john doe",
this.email = "[email protected]",
this.address = "ukay perdana"
this.hobbies= ['music','movies','sport'];
this.showHobbies = true;
}
tooggleHobbies(){}
}
我的模板
<h2>Hello {{ name }}</h2>
<h2>email : {{ email }}</h2>
<h2>address : {{ address }}</h2>
<h2>hobby</h2>
<ul>
<li ngFor="let hobby of hobbies">{{ hobby }}</li>
</ul>
但ngFor
不显示任何数据:
我试着的代码,但他们没有很多风格的作品对我来说: -
<ul>
<li *ngFor="let hobby of hobbies">{{ hobby }}</li>
</ul>
<ul>
<li *ngFor="#hobby of hobbies">{{ hobby }}</li>
</ul>
<ul>
<li ngFor="#hobby of hobbies">{{ hobby }}</li>
</ul>
我的代码有什么问题?这是我的角度版本
@angular/cli: 1.0.0-beta.31
node: 6.9.2
os: win32 x64
@angular/common: 2.4.7
@angular/compiler: 2.4.7
@angular/core: 2.4.7
@angular/forms: 2.4.7
@angular/http: 2.4.7
@angular/platform-browser: 2.4.7
@angular/platform-browser-dynamic: 2.4.7
@angular/router: 3.4.7
@angular/cli: 1.0.0-beta.31
@angular/compiler-cli: 2.4.7
我只是想'
有没有错误?图片显示一个点,所以“li”显示正确?开发工具中元素的外观如何?上面的列表中添加''
以确保上下文有你期望 –