question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ionic2 Pipes is not working in modal

See original GitHub issue

Short description of the problem:

I have created modal using given below format

Beta 10 code

let demo = Modal.create(DemoPage, { ID: id });
 this.nav.present(demo);

if i present modal window like this TranslatePipe is working

but this same code is not working in beta 11

Beta 11

let demo = this.modalCtrl.create(DemoPage, { ID: id}); 
demo.present();

Js code :

import {TranslatePipe} from "ng2-translate/ng2-translate";
@Component({
    templateUrl: "build/pages/demo/demo.html",
    providers: [[DemoService]],
    pipes: [TranslatePipe],
    queries: {
        content: new ViewChild(Content)
    }
})

export class DemoPage {
}

HTML

 <ion-title>{{ 'Demo.title' | translate}}</ion-title>

*Which Ionic Version? * ionic 2 beta 11

Run ionic info from terminal/cmd prompt: (paste output below) Cordova CLI: 6.3.0 Gulp version: CLI version 3.9.1 Gulp local: Local version 3.9.1 Ionic Framework Version: 2.0.0-beta.11 Ionic CLI Version: 2.0.0-beta.33 Ionic App Lib Version: 2.0.0-beta.19 OS: Distributor ID: Ubuntu Description: Ubuntu 14.04.5 LTS Node Version: v4.4.7

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:9

github_iconTop GitHub Comments

3reactions
szernercommented, Aug 9, 2016

I think this could be an issue not special for modals but for all overlays (see issue #7592). You could try the following in your app.ts (excerpt):

import {TRANSLATE_PROVIDERS, TranslateService, TranslatePipe, TranslateLoader, TranslateStaticLoader} from 'ng2-translate/ng2-translate';
...
ionicBootstrap(MyApp, [
    {   provide: PLATFORM_PIPES,
        useValue: TranslatePipe,
        multi: true},
    {
        provide: TranslateLoader,
        useFactory: (http: Http) => new TranslateStaticLoader(http, 'assets/i18n', '.json'),
        deps: [Http]
    },
    TranslateService
    ], { }
);

Then in your modal you should omit the pipes: [TranslatePipe] statement of the @component decorator.

This works for my translations in v2 beta 11.

1reaction
bibitoocommented, Feb 2, 2017

I have got this problem now. Since PLATFORM_PIPES has been deprecated, in RC6, How should I do?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Modal window inside pipes is not working - Ionic Forum
Modal window inside pipes is not working ... import {NavController, MenuController, NavParams, ViewController, Events} from “ionic-angular”;
Read more >
Angular number pipe doesn't work in a modal - Stack Overflow
I get an error - Error: NG0302: The pipe 'number' could not be found! when I used it in a modal of my...
Read more >
Ionic Docs Example - StackBlitz
A angular-cli project based on rxjs, tslib, zone.js, core-js, @angular/core, @angular/router, @angular/common, @angular/compiler, @angular/animations, ...
Read more >
How to Build an Ionic 5 Calendar with Modal & Customisation
The last missing piece is the modal view with some items as input fields and the calendar component just like before, but this...
Read more >
How to Build an Ionic 5 Calendar with Modal & Customisation
Having a calendar component in your Ionic app could be an essential element for your whole app experience, and while there's not a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found