No provider for service error in angular2, why do I need to inject it in it's parent component?
问题 I have a pages.service.ts import { Injectable } from '@angular/core'; import { ApiService } from '../../apiService/api.service'; import { Playlists } from '../shared/playlists.model'; @Injectable() export class PagesService { private currentPlaylists: Subject<Playlists> = new BehaviorSubject<Playlists>(new Playlists()); constructor(private service: ApiService) { } } This pages service needs another service called ApiService , I inject the way as shown above, it works. I bootstrap ApiService