globalizejs / globalizejs/globalize

Integrate Globalize with Angular

Open
#916 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
4.8k
Forks
585
PR merge metrics
No merged PRs in 30d

Description

Hi folks

I'm trying to get Globalize running on Angular and it seems to me that it's not so easy. I haven't found any full examples on how to do that and only some incomplete samples.

Basically, I have the following component, but I always get the following error `currencyFormatter is not a function`:

```typescript
import { Component } from "@angular/core";
import { AuthenticationService } from "../services/AuthenticationService";
import { Router } from "@angular/router";
import likelySubtags from "cldr-data/supplemental/likelySubtags.json";
import * as cldr from "cldrjs";
import * as Globalize from "globalize";

@Component({
selector: "app-index",
templateUrl: "./index.component.html",
styleUrls: ["./index.component.css"],
})
export class IndexComponent {
currency = 123;
formattedCurrency = "";

constructor(
private router: Router,
private authService: AuthenticationService
) {
Globalize.load(likelySubtags);
const formatter = new Globalize("de").currencyFormatter("USD");
this.formattedCurrency = formatter(Math.PI);
}

}

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.