No provider error for Injectable


#1

Hi,

ive got a problem when injecting my service… it worked with the last beta (now i’m on 2.0.0-beta.32).
The error message is the following:
Unhandled Promise rejection: EXCEPTION: Error in :0:0 ORIGINAL EXCEPTION: No provider for FussballService! ORIGINAL STACKTRACE: Error: DI Exception at NoProviderError.BaseException [as constructor] (file:///android_asset/www/build/js/app.bundle.js:3015:23) at NoProviderError.AbstractProviderError [as constructor] (file:///android_asset/www/build/js/app.bundle.js:24318:16) at new NoProviderError (file:///android_asset/www/build/js/app.bundle.js:24354:16) at ReflectiveInjector_._throwOrNull (file:///android_asset/www/build/js/app.bundle.js:25337:19) at ReflectiveInjector_._getByKeyDefault (file:///android_asset/www/build/js/app.bundle.js:25365:25) at ReflectiveInjector_._getByKey (file:///android_asset/www/build/js/app.bundle.js:25328:25) at ReflectiveInjector_.get (file:///android_asset/www/build/js/app.bundle.js:25137:21) at ElementInjector.get (file:///android_asset/www/build/js/app.bundle.js:26719:48) at ElementInjector.get (file:///android_asset/www/build/js/app.bundle.js:26719:48) at ReflectiveInjector_._getByKeyDefault (file:///android_asset/www/build/js/app.bundle.js:25362:24)

I use the FussballService in my Fussball-View:
`@Page({
templateUrl: ‘build/pages/fussball/fussball.html’,
providers: [FussballService]
})
export class Fussball {
static get parameters() {
return [[NavController], [NavParams], [FussballService]];
}

constructor(nav, navParams, fussballService) {
    this.fussball = fussballService;
}`

There it works fine, now i want to redirect to another page and use the same service again but without creating a new instance of FussballService:
`@Page({
templateUrl: ‘build/pages/fussball/spielplan/spielplan.html’
})
export class Spielplan {
static get parameters() {
return [[NavController], [FussballService]];
}

constructor(nav, fussballService) {
    this.fussball = fussballService;
}`

Anybody know what i’m doing wrong?


#2

First thing I think is to upgrade you app code to latest beta.10, the ionic command line tool seems to have to be synced to the framework version, 32 being the latest cli version, you framework may not be matching. latest beta.10 has deprecated @Page in favor of @Component that might be the cause. Actually it was deprecated in beta.8 already.


#3

Oh ok, where can i see how the latest app code syntax is?


#4

Check here … you can check the dropdown for all previous versions or upcoming one’s


#5

You may also follow up the change log https://github.com/driftyco/ionic/blob/master/CHANGELOG.md


#6

Thanks :slight_smile: