question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to get formatted value?

See original GitHub issue

Hi!

I want to get the formatted value from v-model. How can I do that? I miss an API function like getFormattedValue(). Or is there another way to get the formatted value?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
Ambratolmcommented, Apr 17, 2021

You can convert the formatted value you get from v-model to a raw number value using the API functions like parse function:

Parse Function Parses a currency formatted string emitted by the v-currency directive to a number. This method is also exposed as Vue instance method $ci.parse when installed as Vue plugin.

Example: const rawValue = VueCurrencyInput.parse(formattedValue, options);

Options are The configured options of the respective v-currency directive. When using $ci.parse this argument is optional and defaults to the globalOptions of the plugin options.

So, in options parameter make sure to put the same options object you defined on the input that the formattedValue is coming from.

For example you have in template: <input v-model="myVal" v-currency="myValOpts" />

And in your script data section:

data() {
    myVal: 0,
    myValOpts: {
              currency: { prefix: "$ " },
              precision: 2,
              allowNegative: false
              // ....etc
    }
}

Then, you get the raw value this way: const myRawVal= VueCurrencyInput.parse(myVal, myValOpts);

I hope it helps 😃

0reactions
phlegxcommented, Apr 17, 2021

Thank you so much!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to get formatted value of variable in its standard ...
One trick I have seen is to create a copy of your format library where all of your format labels (decoded values) have...
Read more >
Get Formatted Value of Cell in Excel
Use the TEXT() function: TEXT(value, format_text) So if the value is 23.5 and you pass =TEXT(A1, "$0.00") it will return $23.50
Read more >
DataGridViewCell.GetFormattedValue Method
A TypeConverter associated with the formatted value type that provides custom conversion from the value type, or null if no such custom conversion...
Read more >
Retrieving formatted values from D365/CDS with Microsoft Flow
To get the formatted value from one of the values you are iterating over you can use items('Apply_to_each')?['fieldname@OData.Community.Display.
Read more >
How to Get Formatted values in c# code from Multis...
OptionSetValueCollection op= (OptionSetValueCollection)item["new_multiselectoptionset"]; foreach (var options in op) { int i = options.Value; } ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found