January 14, 2017
“Intl is not defined” with Angular 2
If you are using the date, currency, decimal or percent pipes in Angular 2 make sure to add the required Intl Polyfill to your application before you ship it to production. The Internationalization API is not yet implemented in all browser versions out there. If you forget this you’ll receive the Intl is not defined
error in many browsers. Especially Internet Explorer 9 and 10. You can get a full overview at caniuse.com
Dependent on what features of Angular 2 are used, you actually might need some other polyfills. So make sure to check the browser support page on angular.io before you release your app to the web.
Following an example on how to add Intl Polyfill to angular-cli:
1 |
npm install intl --save |
Update your polyfill.ts
1 2 3 4 |
... import 'intl' import 'intl/locale-data/jsonp/en.js' |
Thats it!
wonderful
Great!!!
unbelievable