Home » Javascript » select not selecting programmatically after i select in angular js [on hold]

select not selecting programmatically after i select in angular js [on hold]

Posted by: admin August 19, 2018 Leave a comment

Questions:

Selecting item in select tag programmatically is working but after selecting using mouse, programmatically selecting not works. Please help me how to solve this.

Load -> Select programmatically works

Load -> Select using mouse -> Select programmatically not working

This is my code:

<div class="input-field col s12">
                <label for="branch_fk" class="active">Branch</label>
                <select ng-model="selectedEmployeeBranch" ng-options="b.name for b in branches track by b.id"></select>
            </div>

This is the JS code:

$scope.editEmployeeData = function(){
        if($scope.editEmployeeFields.id){
            $scope.selectedEmployeePosition = $scope.positions.find(function(p){
                return p.id==$scope.editEmployeeFields.position_fk;
            });
            $scope.selectedEmployeeBranch = $scope.branches.find(function(b){
                return b.id==$scope.editEmployeeFields.branch_fk;
            });
            $scope.editEmployeeFields.gender = $scope.editEmployeeFields.gender+"";
            $("#editEmployee").modal("open");
        }
        else{
            alert("Select employee");
        }
    }
    $scope.test = function(){
        $scope.selectedEmployeeBranch = $scope.branches[0];
    }
$scope.editEmployee = function(p,b){
        $scope.editEmployeeFields.position_fk = p.id;
        $scope.editEmployeeFields.branch_fk = b.id;
        dbOperations.processData("EditEmployee",$scope.editEmployeeFields).then(function(res){
            getEmployees();
            $("#editEmployee").modal("close");
        });
    }
Answers: