Ser*_*eev 11 javascript internationalization angular angular5
我将Angular更新到版本5并得到此错误
在我看来,这一行中的管道错误
<h5>{{ event.date | date:"yyyy.MM.dd"}}</h5>.
有谁知道如何解决这个问题?
Иго*_*нюк 13
看起来你没有更新你的管道,因为breacking变化的角度5见:https://github.com/angular/angular/blob/master/CHANGELOG.md
预定义的格式(short,shortTime,shortDate,medium,...)现在使用CLDR给出的模式(就像在AngularJS中一样)而不是intl API中的模式.你可能会注意到一些变化,例如,对于en-US,shortDate将是8/15/17而不是8/15/2017.
现在GAGGGG而不是G的缩小版eras,格式G现在类似于GG和GGG.
时区Z现在将输出ISO8601基本格式,例如+0100,您现在应该使用ZZZZ来获得GMT + 01:00.
您还需要在app.module中提供您的语言,如下所示:
小智 8
快速修复:为您的语言环境添加导入。对于“ru”,您应该在 app.module 中添加以下行:
import '@angular/common/locales/global/ru';
Run Code Online (Sandbox Code Playgroud)
我已经更新了 app.mudule.ts 以本地化日期。
// app.mudule.ts
...
import { NgModule, LOCALE_ID } from '@angular/core';
import { registerLocaleData } from '@angular/common';
import localeRu from '@angular/common/locales/ru';
registerLocaleData(localeRu);
@NgModule({
...
providers: [
...
{ provide: LOCALE_ID, useValue: 'ru' }
],
bootstrap: [AppComponent]
})
// feed-list-item.component.html (nothing was updated here)
...
<span>{{ event.date | date:'fullDate'}}</span>
...
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5955 次 |
| 最近记录: |