Skip to content

Declaration or statement expected. #952

@q3e

Description

@q3e

I get an error when replicating the angular2 official tutorial
The file is app.component.ts

import {Component} from '@angular/core';
@Component({
    selector: 'my-app',
    template: `
      <h1>{{title}}</h1>
      <h2>My Heroes</h2>
        <ul class="heroes">
          <li *ngFor="let hero of heroes">
            <span class="badge">{{here.id}}</span> {{hero.name}}
          </li>
        </ul>
      <h2>{{hero.name}} details!</h2>
      <div>
        <label>id: </label>{{hero.id}}
      </div>
      <div>
        <label>name: </label>
        <input [(ngModel)]="hero.name" placeholder="name">
      </div>
      `
})
export class AppComponent {
  title = 'Tour of Heroes';

  hero: Hero = {
    id: 1,
    name: 'Windstorm'
    };
}
export class Hero {
  id: number;
  name: string;
}
var HEROES: Hero[] = [
  { "id":11, "name": "Gandhi"},
  { "id":19, "name": "Tesla"},
  { "id":20, "name": "Saladin"},
];
public heroes = HEROES; // error:Declaration or statement expected.

when I hit save I get this alert:
Compile failed but emit succeeded
This error prevents me from running the lite sever with npm start.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions