有人可以告诉我使用我的代码发生了什么,它不断地说'无法编译'。我发现别人的答案,但我的代码看起来不错。仍然不知道根源是什么。谢谢。Angular Demo中的TypeScript错误
的代码:
import { Component } from '@angular/core';
export class Hero {
id: number;
name: string;
}
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
template: `<h1>{{title}}</h1>
<h2>{{hero.name}} details!</h2>
<div><label>id: </label>{{hero.id}}</div>
<div><label>name: </label>{{hero.name}}</div>
`
})
export class AppComponent {
title = 'Tour of Heroes';
hero: Hero = {
id: 1,
name: 'Windstorm'
};
}
的错误消息:
ERROR in E:/workspace/angular-tour-of-heroes/src/app/app.component.ts (22,1): Unused label.
ERROR in E:/workspace/angular-tour-of-heroes/src/app/app.component.ts (22,7): Cannot assign to 'Hero' because it is not a variable.