我打算通過angular2.0演示應用程序,但似乎注射器不從構建24工作,並給我錯誤爲
「原始錯誤:無法解析MyAppComponent的所有參數。確保他們都有有效的類型或註釋。「
,直到建立23其工作正常,請幫助我的問題
下面是演示代碼,我提出了從最初的幾個操作只是爲了學習目的injectables不能工作在角2.0最新版本26
import {Component, View, bootstrap, NgFor} from 'angular2/angular2';
module foo{
class FriendsService {
names: Array<string>;
constructor() {
this.names = ["Alice", "Aarav", "Martín", "Shannon", "Ariana","Kai"];
}
}
@Component({
selector: 'array',
injecetables: [FriendsService]
})
@View({
template: '<p>My name: {{ myName }}</p><p>Friends:</p><ul><li *ng-for="#name of names">{{ name }}</li></ul>',
directives: [NgFor]
})
export class arrayComponent {
myName: string;
names: Array<string>;
constructor(friendsService: FriendsService) {
this.myName = 'Alice';
this.names = friendsService.names;
}
}
}
bootstrap(foo.arrayComponent);
以上解決方案不工作仍然給我同樣的錯誤,還有什麼我在上面的代碼中缺少 –
'appInjector'已被刪除@ alpha.29,此解決方案將不再工作。現在必須使用'hostInjector'或'viewInjector' – shmck
我有上面提到的同樣的問題,我已經嘗試了hostInjector和viewInjector,但仍然是相同的錯誤。你能指出一些東西,說明如何正確使用這些東西嗎? – davertron