简体   繁体   中英

How to use Globalize with Angular CLI

How do I load the Globalize library along with the CLDR data in an Angular app generated from angular cli. When I perform the following steps:

  1. npm install globalize cldr-data
  2. import {Globalize} from 'globalize'; in app.component.ts
  3. ng serve

I get this error:

Can't resolve 'cldr' in '/Users/temp-user/cldr-app/node_modules/globalize/dist'
 @ ./~/globalize/dist/globalize.js 22:2-25:14
 @ ./~/globalize/dist/node-main.js
 @ ./src/app/app.component.ts
 @ ./src/app/app.module.ts
 @ ./src/main.ts
 @ multi webpack-dev-server/client?http://localhost:4200 ./src/main.ts

EDIT:

Also tried including it in scripts in angular-cli.json

  "scripts": [
     "../node_modules/cldrjs/dist/cldr.js",
     "../node_modules/globalize/dist/globalize.js"
  ],

just including any library wont suffice to use it, you need to configure it in angular-cli.json file.

"scripts": [
  ... path to global libraray
]

Read more about Global Library Installation here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM