Reputation: 3560
I have an issue while trying to get value from input field using Angular.js. I am explaining my code below.
In my controller code is given below.
$scope.shipping=0;
$scope.addProductInfoData=function(billdata){
console.log('valid',$scope.shipping);
}
My view part is given below.
<div class="input-group bmargindiv1 col-md-12">
<span class="input-group-addon ndrftextwidth text-right" style="width:180px">Shipping charge :</span>
<div ng-class="{ 'myError': billdata.ship.$touched && billdata.ship.$invalid }">
<input type="text" name="ship" id="shippingcharge" class="form-control" placeholder="Add shipping charge" ng-model="shipping" ng-keypress="clearField('shippingcharge');" ng-pattern="/^[0-9]+([,.][0-9]+)?$/">
<div style="clear:both;"></div>
</div>
</div>
<div class="help-block" ng-messages="billdata.ship.$error" ng-if="billdata.ship.$touched || billdata.usp.$error.pattern">
<p ng-message="pattern" style="color:#F00;">This field needs only number(e.g-0,1..9).</p>
</div>
<input type="button" class="btn btn-success" ng-click="addProductInfoData(billdata);" id="addProfileData" value="Add"/>
Here when i am clicking on add button inside console message i should get the shipping value is 0.But here i am getting value as undefined.Please help me to resolve this issue.
Upvotes: 0
Views: 131
Reputation: 7266
You haven't defined a shipping_status
. That is why it equals to undefined
. May be you have a typo in your variable name or intend to use $scope.shipping
.
Change this
console.log('valid',$scope.shipping_status);
to
console.log('valid',$scope.shipping);
Upvotes: 2