Below is an array:
$scope.age = 2;
$scope.people = [{name:"Sam",age:2},{name:"Pam",age:3},{name:"Ham",age:4}]
The requirement is to make the ng-options dynamic. When age is 2, display all people objects in ng-options. If age is 1, show only the object with the name "Sam".
The $scope.age
variable can be either 1 or 2.
How can this functionality be achieved in AngularJS without having separate select statement blocks for each condition?