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.
upd @grayfox pointing out correct way (see comment bellow):
for future references - use
--emitdecoratormetadataflag when using tsc or addemitdecoratormetadata: trueconfiguration if you're using gulp-typescript
see typescript compiler options here (you can find emitdecoratormetada there).
Comments
Post a Comment