Instead of writing the same function 6 times for different relationships between a select box and an input field, I want to pass the ng_model reference of the input to the ng-Change function of the select box. This way, when the select box is changed, the function can update the referenced model automatically.
Update
This is my current setup:
<select id="name_select" ng-model="name_model" ng-change="getAU_name(type_model,name_model)" ng-selected="name_model" ng-options="user.name as user.name for user in AU_model[type_model]" required></select>
<input id="description_input" ng-model="description_model" disabled></input>
$scope.getAU_name = function (type, name) {
$.each($scope.AU_model[type], function (index, value) {
if (value.name == name || value.description === name) {
console.log("name= " + value.name + " description= " + value.description);
$scope.description_model = value.name;
}
});
However, because I have 6 similar relationships, I want to avoid repeating the getAU_name function just to set the $scope.description_model
.
In essence, I have multiple models like description_model
, description_model_2
, etc., that I want to update with the same function.