Ionic 2, Using Angular 2 Pipe Breaks on iOS-"Can't Find Variable: Intl"

How to use currency and date filter for IOS in Ionic 2?

That's because it relies on the internalization API, which is not currently available in all browsers (compatibility table).

You can try to use a polyfill for Intl like this:

npm install --save intl

And then, add these imports to your app:

import 'intl';
import 'intl/locale-data/jsonp/en';

Ionic 2 - How to Import Intl polyfill

Normally the polyfill.ts is imported in the app module file that'll bootstrap your application normally this is the main.ts file, so importing the needed polyfill in the app module bootstrap file should do the trick.

Here is an example:

main.ts

import './polyfills.ts';

import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import {enableProdMode} from '@angular/core';

import {environment} from './environments/environment';
import {AppModule} from './app/app.module';

if (environment.production) {
enableProdMode();
}

platformBrowserDynamic().bootstrapModule(AppModule);

polyfill.ts

// All needed polyfills for example web animations
import 'web-animations-js/web-animations.min';

Date formatter is not working when using with ionic and angular v2

Install intl package (or update package.json):

npm install intl

In polyfill.ts or main.ts

import 'intl';
import 'intl/locale-data/jsonp/en.js';

Tested and working for Safari.

Ionic-Angular binding not removing DOM element, null number format causes binding to fail

We had a similar issue, which we resolved with the following workaround: We implemented a custom pipe which used JavaScript's native formatting:

if(value === null) {
return "";
}
Intl.NumberFormat().format(value);

The elegance of this is that we removed the burden of formatting from the view plus I think in your case it will remove the pipe chaining.



Related Topics



Leave a reply



Submit