にHttp
サービスを注入しようとするとこのエラーが発生します。注入エラー:すべてのパラメータを解決できません
import {Component} from 'angular2/core';
import {Http} from 'angular2/http';
export class PanelsService {
constructor(public http:Http) { }
getPanelFilters() {
var url = '../../data/panelFilters/' + 13677 + '.json'
return this.http.get(url)
}
}
私は私のSidebarComponent
からPanelsService
にアクセスしようとしています:私は使用して試した
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
:
import {PanelsService} from '../panels/panels.service';
@Component({
....
providers: [PanelsService]
})
export class SidebarComponent implements OnInit {
constructor(public panelsService:PanelsService) { }
ngOnInit() {
console.log('I am the sidebar component');
}
}
私のtsconfig.json
もラインを持っていることに留意すべきです@Injectable
が実証済みのようにhereですが、私のクラスを@Injectable()
で飾ると、 OLE:
boot.js
は、単に私のアプリのコンポーネントをブートストラップし、それはすべての依存関係を注入しない:
import {bootstrap} from 'angular2/platform/browser';
import {AppComponent} from './components/app.component';
bootstrap(AppComponent).catch(err => console.error(err));
任意の助けいただければ幸いです。
スクリプトタグにhttpバンドルを含める必要があります。 –
@ EricMartinezちょうどそれを実現しました - ありがとう – garethdn