I have this value here:
{{step1.$valid}}
which returns false. What I am trying to do is get the text "false" to appear in an input text box:
<input type="text" ng-model="user.stepValidation" ng-value="{{step1.$valid}}"/>
I have also tried value and ng-bind and neither of these get the value from {{step1.$valid}} to appear in my input text...please help.
Try this:
<input type="text" ng-model="user.stepValidation.step1.$valid"/>
Here's a Fiddle.
Related
i need to pass value from vue to textbox, doing for one day but still didn't work.
my html input type code
<input type="hidden" id="variation" name="variation" v-model="variation">
second is my is my value is appear on paragraph
<p name fs="paragraph" fw="semi-bold" color="dark">{{ getVariantTitle(variant) }}</p>
its works for passing value to paragraph but not working for passing value into hidden html textbox. i really need value for passing into form post.
As the input type is hidden, instead of v-model just try using v-bind:value, as you don't need two way binding for a hidden input
I am sure there is better way to achieve what you're trying to do but for a quick fix you can try using v-bind instead of v-model
<input type="hidden" id="variation" name="variation" v-bind:value="variation">
This means the hidden text field will always have the same value as this.variation
EDIT:
<input type="hidden" id="variation" name="variation" :value="getVariantTitle(variant)">
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
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
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)">
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.
I have input :
<input type="text" id="nameProduct">
I want set value :
document.getElementById("nameProduct").value="hello";
How can I do it before page load input ?
You can't do it with JavaScript, the dom element object can only get after it loaded. The right way is to set value attribute for input.
<input type="text" id="nameProduct" value="hello">
A simple hack you can do is hide element initially and show it after value updated using JavaScript.
var ele=document.getElementById("nameProduct");
ele.value="hello";
ele.style.display='block';
<input type="text" id="nameProduct" style="display:none">
I am new to angularjs. Trying to use it to build simple applications. I have a textbox in html with a default initial value of "Abc".
<input type="text" value="Abc">
Now, I want to fetch the value which is there in textbox. For that I am using ng-model directive.
<input type="text" ng-model="demo" value="Abc">
But as soon as I enter ng-model directive in input, the default value in text box disappears and it shows a blank textbox. Any ideas why?
That is the desired functionality - Angular way
<input type="text" ng-model="demo" value="Abc">
function Main($scope) {
$scope.demo = 'Abc';
}
Another workaround is by using ng-init:
<input type="text" ng-model="demo" ng-init="demo='Abc'" value="Abc">
For reference : Input default value
I have a textbox which is empty, but when i inspected, it has following html:
<input data-bind="value: optionName, namePath: true" id="QuestionOptions_0__Text" name="QuestionOptions[0].Text" onkeyup="AddToGroupOption(this.id);" type="text" value="Male"></input>
I am trying to get value of textbox as:
$('#QuestionOptions_0__Text').val()
and
$('#QuestionOptions_0__Text').attr('value')
but it always returns ""
How can i get the value,
Plz guide me,
Thanx
Ok,
I have found the solution, I can access the value by:
$('#QuestionOptions_0__Text').prop('defaultValue')