I am trying to push an array of values inside select box using ng-options in Angularjs.
Handlebars:
<div class="col-md-8">
<select ng-options="item as item.label for item in items track by
item.id" ng-model="selected">
<option></option>
</select>
</div>
Controller:
var app = angular.module('myapp', []);
app.controller('mycontroller', function($scope) {
$scope.arealistArray=[];
$scope.items=[];
for(j=1;j<3;j++){
$scope.arealistArray.push([{id: 'id'+j,label: 'aLabel'+j,subItem: {
name: 'aSubItem'+j }}]);
}
$scope.items = $scope.arealistArray;
My options are appending in the select box, but the value and label are undefined for appended options. Is there any restriction using push in ng-options? Or any thing I want to change here?