app.controller('HelloController', function($scope) {
console.log($scope.input1);
console.log($scope.input2);
if (($scope.op_option == 4) && ($scope.input2 == 0)) {
myForm.$invalid;
}
});
<form id="calc" method="post" action="/" ng-app="myApp" name="myForm" ng-controller="HelloController" novalidate>
<div class="row">
<div class="col-xs-2">
<input type="number" class="form-control" name="op1" placeholder="Enter 1st number" ng-model="input1" required>
<span style="color:red" ng-show="myForm.op1.$dirty && myForm.op1.$invalid">
<span ng-message="myForm.op1.$error.required">Number is required</span>
</span>
</div>
<div class="col-xs-2">
<select class="form-control" name="op_option" ng-model="oper">
<option value="1">+</option>
<option value="2">-</option>
<option value="3">*</option>
<option value="4">/</option>
</select>
</div>
<div class="col-xs-2">
<input type="number" class="form-control" name="op2" placeholder="Enter 2nd number" ng-model="input2" required>
<span style="color:red" ng-show="myForm.op2.$dirty && myForm.op2.$invalid">
<span ng-message="myForm.op2.$error.required">Number is required</span>
</span>
</div>
</div>
<br>
<div class="row">
<div class="col-xs-12">
<button type="submit" class="btn btn-success" ng-disabled="myForm.$invalid">Calculate</button>
</div>
</div>
</form>
The purpose of this code snippet is to verify if the selected operation is division (i.e., option 4) and if the second input value is 0. In such a case, we want to prevent dividing by zero by disabling the submit button. The issue encountered is that the browser console displays 'undefined' for $scope.input1. Assistance in resolving this matter would be greatly appreciated