i use ng-options show data in array of object.
index.html
<select ng-model="object_choose" ng-options="values.id values.label values in array_object"> </select> <button ng-click="get_my_array()">get array</button> controller.js
app.controller('ctrl', function ($scope) { $scope.array_object = [ {"id": "a", "label": "a", "my_array": [1, 2, 3, 4]}, {"id": "b", "label": "b", "my_array": [1, 4, 8]}, {"id": "c", "label": "c", "my_array": [2,6]} ]; $scope.get_my_array = (function() { console.log($scope.object_choose); //it work , show "id" , b , c console.log($scope.object_choose.my_array); //it not work }); }); can array in object.
the easiest way store real value in model with:
ng-options="values values.label values in array_object" you can access follows:
console.log($scope.object_choose.id); // , b , c console.log($scope.object_choose.my_array); // array the trick understand many ways can write expression manipulate how data stored , displayed. manual has info need.
Comments
Post a Comment