use*_*529 4 currency date pipe angular
我将 Angular 应用程序从 v10 升级到 v11。
它使用一些标准(非自定义)管道 - 日期、货币、大写等。
日期和货币现在给我错误。例如:
core.js:5980 ERROR Error: InvalidPipeArgument: 'Cannot read property 'toLowerCase' of undefined' for pipe 'DatePipe'
Run Code Online (Sandbox Code Playgroud)
我只是像以前一样导入 std 管道的 CommonModule:
import { CommonModule } from '@angular/common';
Run Code Online (Sandbox Code Playgroud)
小智 6
我的问题是我的 app.module.ts 中有这个:
{
provide: LOCALE_ID,
useFactory: (translate: TranslateService) => {
switch (translate.currentLang) {
case "en":
case "en_GB":
registerLocaleData(localeEN)
break;
case "es":
case "es_ES":
registerLocaleData(localeES)
break;
default:
registerLocaleData(localeEN)
break;
}
return translate.currentLang;
},
deps: [TranslateService]
},
Run Code Online (Sandbox Code Playgroud)
但return translate.currentLang;返回是导致此错误undefined的undefined原因。于是修改一下就return translate.currentLang != undefined ? translate.currentLang : "en";解决了问题。
| 归档时间: |
|
| 查看次数: |
3462 次 |
| 最近记录: |