Is there a way to include a space or special character after the "₹" symbol?
Desired output: ₹ 49
Current output: ₹49
HTML - {{cart.getTotalPrice() | currency:"₹"}}
Is there a way to include a space or special character after the "₹" symbol?
Desired output: ₹ 49
Current output: ₹49
HTML - {{cart.getTotalPrice() | currency:"₹"}}
Don't bother trying to achieve it with the currency filter. Just stick to using the number filter.
<div ng-controller="MyCtrl">
<input class="tb" ng-model="numberInput" type="text" /> {{ "₹ "+(numberInput | number:2) }}
</div>
DEMO
var app = angular.module("app", []);
app.controller('AddSiteURLCntr', function($scope, $sce) {
$scope.numberInput = '1275.23';
})
<!DOCTYPE html>
<html>
<head>
<script data-require="<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="caaba4adbfa6abb8e4a0b98afbe4fee4fd">[email protected]</a>" data-semver="1.4.7" src="https://code.angularjs.org/1.4.7/angular.js"></script>
<link rel="stylesheet" href="style.css" />
<script src="script.js"></script>
</head>
<body ng-app='app'>
<div ng-controller="AddSiteURLCntr">
<input class="tb" ng-model="numberInput" type="text" /> {{ "₹ "+(numberInput | number:2) }}
</div>
</body>
</html>
Give this a shot
Check it out
<span ng-bind="displayPrice(cart.getTotalPrice())"></span>
<span ng-bind="extractCurrency(cart.getTotalPrice())"></span>
Handler
$scope.displayPrice = function (item) {
return ($filter('currency')(item,'$')).substring(0,1);
}
$scope.extractCurrency = function (item) {
return ($filter('currency')(item,'$')).substring(1,item.length);
}
<!DOCTYPE html>
<html>
<head>
<title></title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.1/angular.min.js"></script>
</head>
<body ng-app="my-unique-app">
<div ng-controller="my-custom-controller">
<input type="number" name="price" ng-model="totalPrice">
<p>{{getTotalPrice() | currency : "₹ "}}</p>
</div>
<script type="text/javascript">
var customApp = angular.module("my-unique-app",[]);
customApp.controller("my-custom-controller",function($scope){
$scope.totalPrice = 0;
$scope.getTotalPrice = function(){
return $scope.totalPrice;
}
});
</script>
</body>
</html>
To achieve the desired output, simply add a space after each symbol.
Example - {{change.getPrice() | currency:"$ "}}
Follow this format and you will see the result you want...
If you want to customize the currency filter, you can create your own filter for handling money values...
angular.module('customModuleName').filter('moneyConverter', customFilter);
function customFilter($filter, $locale) {
const formats = $locale.NUMBER_FORMATS;
return function(amount, currencySymbol) {
if (!currencySymbol) currencySymbol = formats.CURRENCY_SYM + ' ';
return $filter('currency')(amount, currencySymbol);
};
}
Once you have created your new filter named 'moneyConverter', you can utilize it in your code like this...
<span>{{vm.totalAmount | moneyConverter}}</span>
Attempting to incorporate material design with routing in angular js, but encountering issues with CSS design not working. Interestingly, when using bootstrap CSS, it functions properly. Check out the Plnker Demo here However, upon trying this approach, ...
My goal is to restrict a text input field to specific characters only. I am looking to allow: alphanumeric characters (a-z A-Z 0-9) 3 special characters (comma, dash, single quotation mark) : , - ' A few accented characters: à â ç è é ê î ô ...
There are two dropdown lists in my code: <div class="control-group"> @Html.LabelFor(x => x.ServiceId) @Html.DropDownListFor(x => x.ServiceId, new SelectList(Model.ServiceList, "Id", "Title"), new { @class = "open" }) &l ...
I'm using a function in my controller to render the "result" in my "home-page" view, which is calling my model to execute the query. exports.searchNoms = (req, res) => { getDatabaseModel.searchNoms(req).then(function(result) { console.l ...
What is the top choice for displaying items in a table format using AngularJS? I have come across several options such as ng-table, ui-grid, ag-grid, and kendo-grid. I require functionalities like sorting, filtering, row styling, header column splitting, ...
Is it possible to have multiple galleries on a single page with captions? I've been trying to incorporate this JavaScript code, but struggling to make the next/previous links function for both galleries. Since I'm new to JavaScript, any advice or ...
Currently, I have a loop that is showcasing a list of items along with their respective sub-items. The data response payload for this operation appears like the following. I have successfully executed the loop and managed to display it on my frontend desi ...
Experimenting with a new technique where I divide my code into separate files to create multiple HTML pages instead of one large one. Using ajax to load them and then setting the content as innerHTML to a parent div results in clean code that works well in ...
Upon reviewing my AWS billing report, I noticed an excessive data transfer of 495.385 GB on my socket.io application running on the EC2 instance. This amount seems too high for a small experimental website like mine. Could this be due to inefficient code i ...
Is it possible to easily turn a watch on or off, or indicate whether the watch should be active right now? I am aware that I can unregister a watch, but how do I register it again? In my scenario, I have hierarchical select lists where changing the parent ...
I'm a beginner in coding, so please bear with me if my question sounds amateurish. Currently, I am developing an e-commerce website where customers can order posters from images uploaded to the site. They should be able to choose the size of the poste ...
Recently transitioned from C# development to diving into Next.js for a client project. Utilizing MUI, I have put in a day of work so far, resulting in a relatively small project. While I grasp the concept of SSR (Server-Side Rendering) theoretically, the ...
Currently, I'm working on a chrome app that utilizes local storage. The backend returns JSON data which I then save locally and encrypt all the items within the JSON. I have multiple sets of JSON with different encryption functions for each set. I at ...
I've been working on a tool to extract elements from an array starting after the first 2 elements. Although I attempted it this way, I keep getting undefined as the result. // ARRAYS var arr = ['one', 'two', 'three', &a ...
Is there a way to input HTML into a text area, then upon submission, have the system read the file, identify the class selector, and separate the HTML into multiple files saved in a directory? If you have any thoughts on how this could be accomplished, pl ...
I am a beginner in JavaScript and I'm facing an issue with displaying the most recent values from a .json file on an HTML page. The file is updated every 10 seconds, and I am also reading it every 10 seconds, but I'm not getting the latest data. ...
Every time I try to close a bootstrap modal (using bootstrap-vue) that includes a vee-validated "update" form with vue.js, I encounter the following error: main.js:477686 Uncaught (in promise) Error: [vee-validate] Validating a non-existent field: "#35". ...
I am currently facing an issue with my autocomplete feature not displaying options correctly. To start off, I am fetching hard coded data from my controller and passing it through an axios call: searchController.php $searchResults = [ 0 => (ob ...
As a newcomer to AngularJS, I'm facing an issue that I need help with. Here's my problem: I have an ng-grid connected to a table. Inside the grid, there are values along with an ID (which is a foreign key from another table). Instead of display ...
Hey there, I'm looking to have a div stay fixed after scrolling within its parent div. <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12"> <div class="fw ofndr-box"> <div class="ofndr-box-half add-here"> <a href="#! ...