What is the best way to add currency to a static class?

Before I changed it to be static, this was the currency code I used -

| currency('£')

Currently, my input field does not include the currency -

<input v-bind:class="{'is-static': !foodItem.editing}" type="text" class="input" v-model="foodItem.price">

I have been trying to add the currency myself but it's causing issues. Any suggestions on how to properly include the currency in my input field? Thank you in advance.

Answer №1

To handle this situation, you can utilize an if-else block:

<div v-if="!foodItem.editing">{{ foodItem.price  | currency('£') }}</div>
<div v-else>{{ foodItem.price }}</div>

When the value of foodItem.editing is false, the is-static class is applied. This results in the currency filter being used.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

PHP script failing to execute if/else statement during AJAX request

I am currently developing a website that heavily relies on Ajax, and I have chosen to use codeigniter for its construction. On the site, there is a form with the post method, and this form is submitted using an Ajax request that calls a function containi ...

The battle between HTML5's async attribute and JS's async property

What sets apart the Html5 async attribute from the JS async property? <script src="http://www.google-analytics.com/ga.js" async> versus (function() { var ga = document.createElement('script'); ga.type = 'text/javascript&apo ...

Vue - Sending parameters to computed properties

I am facing an issue with my current code setup: //someFile.Vue <template> <ABC foo="myPath"/> <template> <script> import ABC from 'somewhere'; export default { components: { ABC }, } </script>   / ...

producing a NaN result when calling a reducer with an integer value

Could anyone assist me with this react-redux code? I have an input field that accepts numbers and adds them to the counter above. My goal is to reset the counter to 0 if the input is not a number, but currently when I type any character other than an int ...

What is the best way for OnSubmit to access an external file?

Recently, I adjusted this code snippet to include the onsubmit attribute with a validation function call. Instead of having the validate function within the same file, I moved it to an external file for better organization. Now, I am wondering how do I e ...

Combining a pair of canvases

Currently, I am utilizing a JavaScript library to create a QR Code. This library generates the QR code by displaying it on a canvas. Nevertheless, my goal is to integrate a background behind this QR Code. I attempted to achieve this by first drawing the b ...

Having trouble establishing a connection between MongoDB and a Node.js Express server on my local machine

While attempting to establish a connection between mongoDB and nodejs express using the post method, I added a logger that should display a message confirming that the database is connected once nodejs listens to mongoDB. However, I encountered an issue wh ...

What is the best way to apply fading effects to three divs containing additional divs?

Looking at this HTML and CSS code: HTML <DIV class="newsPic"></DIV> <DIV class="newsPicTwo"></DIV> <DIV class="newsPicThree"></DIV> CSS .newsPic { width: 500px; height: 200px; } .newsPicTwo { width: 500px; height: 2 ...

cursor misplaced following adjustments to mask

I have a phone number in the format 9999-9999. However, I would like it to be displayed as 99999-9999 when the user inputs an additional digit. The functionality is almost there, but the input is happening in the second-to-last spot instead of the last one ...

The function of the Angular ng-include form action for posting a URL appears to be malfunctioning

When a form post is included in a parent HTML using ng-include, it does not trigger the submission action. <div ng-include src="'form.html'"></div> The code in the form.html file is as follows: <form action="next/login" method = ...

Troubleshooting Problem with Laravel Inertia and Ziggy Link Routing

I’m currently experiencing an issue with my routing. The problem arises in the following scenario: When there is no id query, Inertia functions as expected. https://i.stack.imgur.com/r14bt.png However, after navigating to edit mode and attempting to c ...

I am unable to make changes to the Text Field component in Material-UI

After developing a React App using Material-UI, I decided to create independent Components. Below are the independent components (<PanelDiv/>): render() { return ( <div className="panelDiv-component" style={{display:this.prop ...

Unable to display the retrieved list data using v-for loop from axios get request

I recently started using Vue.js and decided to create a simple HTML website with Vue.js to display data from myphpadmin using axios. Everything was working smoothly until I encountered an issue where I couldn't display the JSON message on my screen. n ...

Integrating a personalized dropdown feature into the Froala editor within an AngularJS environment

After searching for a JavaScript rich text editor that doesn't use frames and allows easy customization of the toolbar with custom dropdowns, I came across the Froala editor. It also offers AngularJS-friendly directives. Previously, I tried using Text ...

How can I incorporate multiple states into a conditional statement in ReactJS?

Is there a more efficient way to achieve this task? I'm struggling to come up with a cleaner solution as the current approach looks messy. I need to check multiple states in an if statement and the only method I can think of right now is the one prese ...

Deactivating checkboxes once the maximum selection has been made through jquery

I need assistance with my jQuery code that is supposed to disable checkboxes in a multidimensional array after reaching the maximum number of selections. However, I am having trouble identifying the issue within the code. Any guidance would be greatly ap ...

Adjust the size of horizontal <li> elements dynamically to keep them in a single row

I've been trying to set up a 'gallery' section on one of my pages, with three elements featured. However, I'm running into an issue where resizing the window or viewing on a smaller screen could cause overlaps or force a second row with ...

What is the best way to incorporate external directives globally in Vue 3?

How can directives be added to a Vue 3 application so that they are globally accessible without the need to include them in each component individually? ...

Guidelines for utilizing Three.js plane

I'm currently working with three.js plane to calculate the distance from a point to a plane. After determining the normal of the plane using points a, b, and c as follows: const v = a.clone().sub(c); const u = b.clone().sub(c); const no ...

What drawbacks should be considered when utilizing meteor.js for development?

After viewing the meteor.js screencast, I was truly impressed by its seamless web application development capabilities, especially in terms of live updates and database synchronization. However, I am curious about its scalability once the website goes live ...