Can someone told me what is going on with my code, it continually says 'Failed to compile'. I found out others' answer, but my code looks good. Still don't know what is the root cause. Thanks.
The codes:
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'
};
}
The Error msg:
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.