Beta 11 modal error with providers?

I’ve updated from beta 10 to beta 11 and everything’s fine except for a modal with the following code:

import {Component} from '@angular/core';
import {AlertController, NavController,ViewController} from 'ionic-angular';
...
import {TranslateService, TranslatePipe, TranslateLoader, TranslateStaticLoader} from 'ng2-translate/ng2-translate';

@Component({
    templateUrl: 'build/pages/modals/newIAS/newIAS.html',
    pipes: [TranslatePipe]
    })
    export class newIAS {
        static get parameters() {
            return [[ViewController],[NavController],[CropModel],[TranslateService],[AlertController]];
        }
    constructor(view,nav,crops,translate,alert){
    ...
    }

I’m getting the following error when trying to access it:

ORIGINAL EXCEPTION: No provider for TranslateLoader! (TranslateService -> TranslateLoader)

Any ideas? Also, given the changes to overlays in beta 11, should I keep using navController in a modal? ( I use it to push new pages in )

2 Likes

Are you adding the translate service in the bootstrap process?

In the app.js you mean? If so, yes. If there’s another place to do so now, I’m not aware of where it’d be.

How are you including them?

Like this:
ionicBootstrap(MyApp, [… , TranslateService], { });

And then in every page that uses it I import with:

import {TranslateService, TranslatePipe, TranslateLoader, TranslateStaticLoader} from 'ng2-translate/ng2-translate';

with:

pipes: [TranslatePipe]

and :

static get parameters() {
    return [ ... ,[TranslateService]];
}
constructor(... ,translate){

In every page that uses it.

Are you using ModalController and following breaking changes Beta 11 notes of Ionic Team?

The page that calls the modal has ModalController, has it added normally and uses the new way of doing .present().

I’m also having exactly the same problem, after I erase all my providers on my modal it works fine.

This is my modal:

My error:
image

Perhaps this (closed) issue on GitHub helps you. I have struggled with the ng2-translate service too since beta 11, and registering all providers/pipes in inicBootstrap solved my problem with translations in modals/popovers (for now at least).

I’ve found a workaround. I’m passing my providers on NavParams, it is not the best way, but seems to work.

it is related to this problem: https://github.com/driftyco/ionic/issues/7160

I’ll look into it; I’m guessing my issue only happens in modals because for every other overlay I create on the same file, instead of calling a different file.

I suppose I’ll use a normal page instead of a modal - which, really, will only make it look different but won’t affect anything else - for the time being as these fixes seem to be temporary.