Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ionic 3.01 Lazy Module : The pipe 'translate' could not be found #506

Closed
pegaltier opened this issue Apr 10, 2017 · 13 comments
Closed

Ionic 3.01 Lazy Module : The pipe 'translate' could not be found #506

pegaltier opened this issue Apr 10, 2017 · 13 comments

Comments

@pegaltier
Copy link

pegaltier commented Apr 10, 2017

**I'm submitting a issue because since the updated Ionic 3.0.0 the ngx-translate cannot be used with ionic lazy loading system.

Current behavior
When i load the page lazy loaded i get :
Uncaught (in promise): Error: Template parse errors: The pipe 'translate' could not be found (" <ion-header> <ion-navbar color="primary" hideBackButton="true"> <ion-title>{{[ERROR ->]"login.title"|translate}}</ion-title> </ion-navbar> </ion-header> "): ng:///LoginModule/LoginPage.html@8:17

Expected/desired behavior

Reproduction of the problem
Load the webapp using : ionic serve

What is the expected behavior?

What is the motivation / use case for changing the behavior?

Please tell us about your environment:

  • ngx-translate version: 6.0.1

  • Angular version: 4.0.0

  • Browser: [all ]

@SamVerschueren
Copy link
Collaborator

Make sure to import TranslateModule in your lazy loaded module as well. Or better, add TranslateModule to a SharedModule and import that SharedModule to every feature module.

@pegaltier
Copy link
Author

pegaltier commented Apr 10, 2017

Hi, @SamVerschueren thanks for your reply. i have done your idea + idea based inside issue 209 and it work in dev mode (ionic serve) but when i build for android it dosn't work. Have you tested with ionic run android ?

#209

@SamVerschueren
Copy link
Collaborator

Have you looked at the AoT section? If yes, provide me with a minimal reproduction case (GitHub repository for instance) and I'll see what I can do. Not much time now to dive into it myself.

@pegaltier
Copy link
Author

Finally i have solved my problem by adding :

// AoT requires an exported function for factories
export function HttpLoaderFactory(http: Http) {
 return new TranslateHttpLoader(http, './assets/i18n/', '.json');
}

And drawing inspiration from : #209

Thanks @SamVerschueren

@SamVerschueren
Copy link
Collaborator

Glad it worked out :)

@pegaltier
Copy link
Author

I have experienced new problem with lazy loading using ion-tabs component.
Have you experienced this component with lazy loading ?

Thanks

@SamVerschueren
Copy link
Collaborator

SamVerschueren commented Apr 11, 2017

No sorry, haven't used ionic that much. This is an ionic issue so please file an issue over there.

@pegaltier
Copy link
Author

Ok i will do this, have a good day!

@pegaltier
Copy link
Author

Finally is ok for the tabs but you must use lazy for all tab inside pager

@wushuai820
Copy link

@pegaltier Do i have the same question that will let me see your code? please

@arthursp
Copy link

I thought the IonicPageModule.forChild() function should resolve this ?

If it's loaded in app.module.ts, why should we add it to each page lazy loaded too ?

@erperejildo
Copy link

@pegaltier I got that error but I use lazy loading for all my pages

@helios1989
Copy link

helios1989 commented Apr 4, 2019

how do you load the json file in lazyloaded module? i don't see in the network tab the translation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants