Select Option 2
In previous chapter we have learn bind dropdown list with array. Now we would try binding dropdown list with object. Below is the example of object with key-value pairs:-
$scope.Employees = {
Emp01 : "Adam",
Emp02 : "Tim",
Emp03 : "John"
};
The expression in ng-options is littlebit different for objects.
In below example we have taken an object which have values in key-value like x present as the key and y present as the value.
One more example where in object we have 3 values as given in below object and
example
$scope.EMployees = {
Emp01 : {EmpName : "Adam", Department : "IT", Skill : "MCA"},
Emp02 : {EmpName : "Tim", Department : "Admin", Skill : "MBA"},
Emp03 : {EmpName : "Bob", Department : "HR", Skill : "MBA"}
};
| |