Angular2 access global service without including it in every constructor से मैं कोड को पकड़ा और थोड़ा है में संशोधित:Angular2 सेवा त्रुटि के लिए कोई प्रदाता
:NoProviderError {message: "No provider for ApiService! (App -> MediaService -> ApiService)", stack: "Error: DI Exception↵
@Injectable()
export class ApiService {
constructor(public http: Http) {}
get(url: string) {
return http.get(url);
}
}
@Injectable()
export abstract class BaseService {
constructor(protected serv: ApiService) {}
}
@Injectable()
export class MediaService extends BaseService {
// Why do we need this?
constructor(s: ApiService) {
super(s)
}
makeCall() {
this.serv.get("http://www.example.com/get_data")
}
}
हालांकि, जब मैं इस कोड मैं कंसोल में कोई त्रुटि मिलती है चलाने का प्रयास
मैं https://plnkr.co/edit/We2k9PDsYMVQWguMhhGl
पर कोड के साथ एक Plunkr बनाया हैकिसी को भी पता है क्या इस त्रुटि का कारण बनता है?