0
我有alpha44的工作代碼,但升級到beta是擊敗了我。我得到這個錯誤:Angular2:沒有<custom service>的供應商
EXCEPTION: No provider for e! (HomeCmp -> RestosSvc -> e)
我在我的引導中包含RestosSvc,並且可以找到該文件。這是我的HomeCmp
import {Component} from 'angular2/core';
import { Resto, RestosSvc } from '../../services/RestosSvc';
@Component({
selector: 'home',
templateUrl: './components/home/home.html',
styleUrls: ['./components/home/home.css'],
directives: [FiltersCmp, ListCmp, MapCmp],
providers: [RestosSvc]
})
export class HomeCmp {
recommendations: Array<Resto> = [];
presetCrits: Object;
selectedResto: number = -1;
top5: boolean;
constructor(public restos: RestosSvc, urlCrits: RouteParams, public router: Router) {
的一部分,這裏是RestoSvc
import {Injectable} from 'angular2/core';
import {Http} from 'angular2/http';
import {Observable} from 'rxjs/Rx';
@Injectable()
export class RestosSvc {
http: Http;
constructor(http:Http) {
我缺少什麼?
請問你RestosService樣子? –
@EricMartinez現在加入 –
Simon,你是否在你的引導中添加了'HTTP_PROVIDERS',對吧?順便說一下,使用'dev'包來獲取完整的錯誤信息,這將有助於您進行調試。 –