Ionic 2 - How to Import Intl Polyfill

I am new to Ionic2 / Angular2, and I inspected and found several solutions for what needs to be done to fix the polyfill problem using intl date formatting (example here: Ionic 2 using Angular 2 Pipe breaks on iOS- "Cannot find variable: Intl "

but the fact that I do not understand, and the fact that the explanation of the overflow of the textbook / stack did not help me figure out exactly where and how exactly to do it. I installed npm to get the intl package added to my node modules, but everything just says β€œthen import it”, but I don’t know where to do it, since I don’t have a polyfill.ts file that I could import it there just the build / polyfill.js file, and I tried to import directly into the .ts file, which uses the intl date manipulation, but this did not solve the problem.

Perhaps I do not understand something completely fundamental, and why no one explicitly indicates where you need to import it, but someone can explain to me how to import it or refer to a resource to explain what I do not understand.

+5
source share
1 answer

Usually polyfill.ts is imported into the file of the application module that will load your application, as a rule, this is the main.ts file, so import the necessary polyfill into the app module the boot 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'; 
+10
source

Source: https://habr.com/ru/post/1264473/


All Articles