I am having trouble retrieving the value from an input field using Angular.js. Below is the code explanation.
Here is my controller code:
$scope.shipping=0;
$scope.addProductInfoData=function(billdata){
console.log('valid',$scope.shipping);
}
And this is my view part:
<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"/>
Upon clicking the add button, I should see the shipping value as 0 in the console message. However, it currently shows as undefined. Can someone please assist me in resolving this issue?