I need to set an object of $scope in AngularJS HTML select tag, I will explain my requirement clearly:
Here is my angularjs script code:
$scope.departments = $http.get("getDepartmentList");
In the department scope I will get list of department objects from spring mvc controller which is fetched from database.
This department scope i will use in html select as
<select name="department"
ng-model="department"
class="form-control"
ng-options="department as department.deptName for department in departments"
class="select_form" >
option
value="">Select Department</option>
</select>
When creation I am able to get department object after selecting from the select list. During modification i will have one department object which need to set and to be selected in the select list but it is not selected only the list of objects is listed without selecting the modified object during modification.
During modification I set scope of department as
$scope.department = $http.get("getDepartmentById);
So the above code will have one department object in scope but it is not selected in the list
I have tried using ng-value in the select tag as
<select name="department"
ng-model="department"
class="form-control"
ng-options="department as department.deptName for department in departments"
ng-value="department"
class="select_form" >
<option value="">Select Department</option>
</select>
But of no use, can anyone help to set the object from the select list in html page.