Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 2 Exception: TypeError: Cannot read property 'annotations' of undefined

What am I doing wrong?

app.component.ts

import {Component} from 'angular2/core';
@Component({
  selector: 'my-app',
  template: `{{title}}`
})
export class App {
  title = "Angular 2 beta";
  constructor() { console.clear(); }
}

main.ts

import {bootstrap} from 'angular2/platform/browser';
import {AppComponent} from './app.component';

bootstrap(AppComponent);

The error is

EXCEPTION: TypeError: Cannot read property 'annotations' of undefined
like image 595
Mark Rajcok Avatar asked Apr 29 '16 15:04

Mark Rajcok


1 Answers

The class name doesn't match what you are bootstrapping. I.e., instead of

export class App { ... }

use

export class AppComponent { ... }

Angular is trying to find the annotations property of a class named AppComponent, but that class doesn't exist, hence the error.

like image 89
Mark Rajcok Avatar answered Oct 02 '22 21:10

Mark Rajcok