Format Number with Globalization plugin

Asked

Viewed 29 times

0

I’m trying to use the plugin cordova.plugin-globalization but I’m bumping into my little Javascript experience.

xhtml:

<div>{{ item.valor | formataValor }}</div>

filter js.:

app.filter('formataValor',function(){
   return function(valor){
       console.log('globalization: '+valor)
       navigator.globalization.numberToString(
           valor,
           function (number) {
               console.log('numero formatado:' + number.value);
               return number.value;
           },
           function () {
               console.log('erro de formatacao de valor');
           },
           {type: 'currency'}
       );
   }
});

Apparently the return of function navigator.globalization.numberToString is getting lost because the console output is ok.

  • The outputs on the console are ok (eg "globalization: 123.4" and "formatted number: 123.40"). The problem is that the html is empty.

  • Github: https://github.com/apache/cordova-plugin-globalization - Documentation: https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-globalization/index.html

  • @Marconi apparently this plugin does not work in browser... only in Android/iOS developers and emulators. If you are testing in browser nvaigator.globalization will be Undefined!

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.