I'm trying to load array objects from a multi-select control, then populate a model object called "name" with its name and age values. After that, I want to load an array from a select element into the model object. However, the ng-model directive on the select control doesn't seem to be working.
<input type="text" class="form-control" ng-model="model.name" placeholder="Enter your name..." />
<input type="text" class="form-control" ng-model="model.age" placeholder="Enter your age..." />
<!--Select pets for the person model-->
<select ng-repeat="pet in arrayFromApi" class="selectpicker" multiple>
<option id="{{pet.id}}" ng-model="model.pets.id">{{pet.name}}</option>
</select>
<script>
var app = angular.module("myApp", []);
app.controller("myCtrl", function($scope) {
$scope.model = { "name":"", "age":"", "pets" :[ {"id":""} ] };
$scope.arrayFromApi = function() {
......
// This function retrieves IDs and names
}
});
</script>