typescript1.5 - Injectables not working in angular 2.0 -


i started playing angular2. i've been trying injectables work half day now, still can't figure out i'm doing wrong.

to keep simple possible, copied code 5 min quickstart in official webpage. demo works fine, when try use injectables, error saying

original error: cannot resolve parameters myappcomponent. make sure have valid type or annotations.

my typescript file

/// <reference path="typings/angular2/angular2.d.ts" /> import {component, view, bootstrap,} 'angular2/angular2';  class names {}  // annotation section @component({     selector: 'my-app',     injectables: [names] }) @view({     template: '<h1>hello {{ name }}</h1>' }) // component controller class myappcomponent {     name: string;     constructor(names: names) {         this.name = 'alice';     } }  bootstrap(myappcomponent); 

p.s. in 5 min quickstart, i'm using traceur, systemjs , angular2 alpha (23)

does know i'm missing?

your compiler not add parameters properties myappcomponent (from looking @ pluker). think problem. if add

myappcomponent.parameters = [[names]] 

then works well.

  1. here plunker fix.
  2. here same example in ts (with es6)

upd @grayfox pointing out correct way (see comment bellow):

for future references - use --emitdecoratormetadata flag when using tsc or add emitdecoratormetadata: true configuration if you're using gulp-typescript

see typescript compiler options here (you can find emitdecoratormetada there).


Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -