Hey guys im trying to inject a service in my app, but im getting some errors.
My service:
import { Injectable } from 'angular2/angular2'; @Injectable() export class FeedLoad { constructor() { console.log("worked"); } }
In my app.ts
import {FeedLoad} from './services/feed-load'; class MyApp { feedLoad: FeedLoad; constructor(feedLoad: FeedLoad) {this.feedLoad = feedLoad} }
Error:
EXCEPTION: No provider for FeedLoad! (MyApp -> FeedLoad)
STACKTRACE:BrowserDomAdapter.logError @ app.bundle.js:36473ExceptionHandler.call @ app.bundle.js:10780(anonymous function) @ app.bundle.js:19823NgZone._notifyOnError @ app.bundle.js:20456errorHandling.onError @ app.bundle.js:20354run @ app.bundle.js:5054(anonymous function) @ app.bundle.js:20369zoneBoundFn @ app.bundle.js:5024p @ app.bundle.js:67(anonymous function) @ app.bundle.js:67Item.run @ app.bundle.js:140drainQueue @ app.bundle.js:110cb @ app.bundle.js:20427arguments.(anonymous function) @ app.bundle.js:5551(anonymous function) @ app.bundle.js:5031run @ app.bundle.js:5051(anonymous function) @ app.bundle.js:20369zoneBoundFn @ app.bundle.js:5024
app.bundle.js:36473 Error: DI Exception
at NoProviderError.BaseException [as constructor] (app.bundle.js:10659)
at NoProviderError.AbstractProviderError [as constructor] (app.bundle.js:11341)
at new NoProviderError (app.bundle.js:11377)
at Injector._throwOrNull (app.bundle.js:9708)
at Injector._getByKeyDefault (app.bundle.js:9759)
at Injector._getByKey (app.bundle.js:9699)
at Injector._getByDependency (app.bundle.js:9685)
at Injector._instantiate (app.bundle.js:9579)
at Injector._instantiateProvider (app.bundle.js:9568)
at Injector._new (app.bundle.js:9557)