1

I can not seem to get the polyfill of the Internationalization API to work. As stated in the docs (https://angular.io/docs/ts/latest/guide/pipes.html) one simply needs to add a script to your index.html:

<script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=Intl.~locale.de"></script> 

And all issues with wrong displayed date pipes should be gone. However this problem still persists.

On another webpage (https://coryrylan.com/blog/adding-the-internationalization-polyfill-to-a-angular-cli-project), I found a more favored solution of installing Internationalization API and adding it to polyfills.ts in angular src folder.

One should npm run install intl --save and then import the intl polyfill like import 'intl'; import 'intl/locale-data/jsonp/de.js'; but this also doesnt work.

Has anyone had success with adding the date polyfill to Angular 4 ?

Some suggested using a custom pipe from moment.js but this can not be a solution for me (Angular2 date pipe does not work in IE 11 and edge 13/14), as such a powerfull beast like angular should provide such a functionality. Maybe I did something wrong?

4

1 回答 1

0

您不能随意使用 angulars datePipe 来格式化日期。像这样:| date: 'HH:mm'这在 chrome 中有效,但不能在边缘显示:08:15。您可以为此使用 Angular 的“shortTime”管道。

编辑 08.05.2017:在 Safari 中仍然面临 InternationalizationAPI 问题的任何人:确保您传递了一个类似的日期{{"2016-07-03T12:33Z" | date 'dd.MM.yyyy'}},因此您需要一个 ISO 字符串表示它才能工作(仅在 safari 中需要),谢谢苹果。

于 2017-04-27T19:19:41.410 回答