Dilip
Dilip

Reputation: 31

input value showing one value but in display coming another value

I am facing one rare issue can some one help me here.

<input class="testVal" type="number" id="GT_FIRING_TEMPERATURE" value="-17" name="degC" onchange="angular.element(this).scope().unitConversion(value,name, id)">

here value is "-17" but in display in input[type='number'] box it is showing my old value "1" in div it is showing proper value -17 it works perfect in div instead of input filed :) I can't understand the problem Please find image here

Upvotes: 0

Views: 59

Answers (3)

Dilip
Dilip

Reputation: 31

here is the solution I found my self

<input class="testVal" type="text"  id="{{item.param_type_value}}" ng-model="item.testCondition" value="{{item.testCondition}}" name="{{item.defUnit}}"    onchange="angular.element(this).scope().unitConversion(this.value,name, id)">

I missed ng-model, and value should be the same ng-model and input type should be text.

Upvotes: 1

Irfan Anwar
Irfan Anwar

Reputation: 1918

Try this as you have not provided full details: in your unitConversion function pass this.value

<input class="testVal" type="number" id="GT_FIRING_TEMPERATURE" value="-17" name="degC" onchange="angular.element(this).scope().unitConversion(this.value,this.name, id)">

Upvotes: 1

Theo Itzaris
Theo Itzaris

Reputation: 4681

Hello something must be wrong with your code,

it is very simple though to bind your input text to a variable.

HTML

 <body ng-controller="MainCtrl">
    <p>Hello {{name}}!</p>
    <input type="number" ng-model="mynumber">
    {{mynumber}}
  </body>

JS

$scope.mynumber = 0;

live example: https://plnkr.co/edit/Inr3vKhuWaulXhythSDk?p=preview

Upvotes: 2

Related Questions