Currency format in AngularJS - javascript

I want to show the number value as currency. The number value comes from the database through MVC controller to cshtml input object with ng-model. I can show the value as currency but according to my scenario i have to change the value and save it using the same input value. How can I do that? Without the currency filter I can change the value and save it. With currency filter I cannot change the input value to save it. The filter prevents me to change the ng-model value. I can change the ng-model value without currency filter.
Can anyone help me?
The filtered and non-filtered input value picture is in the attachment and the input cshtml code is:
<input type="text" id="GiroFeb" autocomplete="off"
ng-model="moneyvalue | currency:'₺'"
ng-change="notifyChange(money.AccountNumber)" />

Related

Typeahead value won't persist when updated with Javascript

Using twitter's typeahead library https://twitter.github.io, if you attempt to update an inputs value with javascript (or jQuery), the value is reset to its original value when the input is selected, and then you click away.
See this gif below
https://gfycat.com/tautsphericalirishdraughthorse
As you can see the typeahead form (with id team2) first contains the string randomstring
When updated with $("#team2").val("test") the change can be seen in the input, but when you select the input and then click away it resets.
Values only seem to persist if you select the box and type in the value.
I need a way where I can alter the value through a js command.

How to format a Number in AngularJs?

I want to format a number from 10000 to 10,000.00 is there any way to do it in HTML alone(without controller file) with ng-Model directive?
I tried to do it in controller file with a logic and bind it to HTML file. But the controller logic always return a number in "10,000.00" String format. Is there any way to convert "10,000.00"(String) to 10,000.00 (number) and bind it to HTML?...(I want 10,000.00 in type number).
My .html file is something like this
div ng-repeat="array in arrayList"><input type="text" ng-Model="array.amount" </div
and my controller file is something like this
var arrayList=[{"amount":3000},{"amount":4000},{"amount":5000}];
(I apologize for not formatting the html file properly)
Thanks
Explanation:
Use type="text" and pattern validation like
pattern="[0-9]+([\.,][0-9]+)*" to limit what the user may enter while
automatically formatting the value as you do in your example.
Put an overlay on top of the input field that renders the numbers how
you want and still allows the user to use the custom type="number"
input controls, like demonstrated here.
The latter solution uses an additional <label> tag that contains the current value and is hidden via CSS when you focus the input field.
In input type: "number" case ngModel type is number and in input type:"text", ngModel is string
Demo of one use-case: JSFiddle

How get get the entered values from input box and not the content of Value attribute

I have some input fields with pre-populated values. After editing the values of this field if the save button is pressed in my script tag I want to take the edited value in the field and send it to my controller using ajax. The problem I faced is when I am picking the value of my input field using
var name = document.getElementById('iusername').value;
I am getting the value in value attribute and not the one resulted after edit.

Gridview template column label values not readable in VB when updated it in Java Script

I am having asp.net grid view with template column fields that includes text box and label. When text box get edited its calculated value assigned to label using javascript, after submission of form when I am trying to read label's value I am getting its old value not the currently updated one, while i am getting correct values from textbox field,
I am using following code to get the values
lblVal= TryCast(oItem.FindControl(cntrlName), Label).Text :- [not getting latest/current value of label, but getting old value]
txtVal = TryCast(oItem.FindControl(cntrlName), TextBox).Text :- [getting latest/current value of text-box ]

How to maintain two values of single field in html

I have a requirement, where i need to show rounded decimal value for the fields in the page. But if user doesn't change the field's value then i need to post the original value of field instead of rounded value and my external library will be called with this posted values.
For example if a have a field 'Initial Temperature' and its value 12.892433 in database, when i populate the field in the page it will be 12.9. Now if user doesnt change this value then i need to post the actual value which is 12.892433.
Can anyone suggest me the best way to do this. I dont want to pull data from the database once i have the posted data.
You can use the data-* attribute, which is used to store custom data private to the page. For example:
<span id="span" data-val="12.892433">12.9</span>
And you can get the value with JS:
var value = $("#span").data("val");
And if you want the value on the server side you can use an input hidden, something like this:
<input type="hidden" name="value" id="value" value="12.892433">

Categories