Currently, I have a select menu with options and a text field that accepts numerical input. The text field needs to adhere to specific ranges based on the selection from the select menu, which is managed through custom validation. My dilemma lies in triggering this validation when the select option changes.
I initially attempted to include an ng-change directive directly in the HTML:
<select ng-change="$scope.my_form.numberField.$validate()">
However, this method proved ineffective. Subsequently, I crafted a function within the controller:
$scope.myFunction = function(){
$scope.my_form.numberField.$validate();
}
Afterward, I modified the select element to call this function:
<select ng-change="myFunction()">
Further experimentation involved tweaking the code within the function:
console.log( $scope.my_form.numberField.$validate() );
Unfortunately, this resulted in an "undefined" output. The corresponding HTML for the text field appears as:
<input type="text" name="numberField" ng-model="numberField" number-validate>
Despite successful validation when directly updating the field, I am at a loss concerning how to automatically trigger it upon changing the select field. Any suggestions or insights would be greatly appreciated.