I want to add a service to another service. I have no problem implementing standard angular services (Http, etc.), but I get an exemption when I try to implement my own services.
Example:
MyService:
import {Injectable, Inject} from 'angular2/core'; import {AnotherService} from '../../services/another.service'; @Injectable() export class MyService { constructor(Inject(AnotherService) private anotherService: AnotherService) { console.log(this.anotherService.get()); } }
AnotherService:
import {Injectable} from 'angular2/core'; @Injectable() export class AnotherService { constructor() { } get() { return 'hello'); } }
When I try to use MyService, I get EXCEPTION: No provider for AnotherService!
I tried using constructor(private anotherService: AnotherService) , still constructor(private anotherService: AnotherService) exception.
Thanks!
source share