globalize icon indicating copy to clipboard operation
globalize copied to clipboard

Integrate Globalize with Angular

Open eluchsinger opened this issue 4 years ago • 1 comments

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:

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);
  }

}

eluchsinger avatar Feb 16 '21 11:02 eluchsinger

@eluchsinger Did you find a solution to this?

mellis481 avatar Oct 10 '23 15:10 mellis481