Reputation: 198
controller.js
$scope.buildings={};
for (var i=0;i<$scope.buildingObj.length;i++){
$scope.buildings.building=$scope.buildingObj[i].building;
console.log($scope.buildings.building);
}
In console am able to print $scope.buildings.building. Now I want to populate $scope.buildings in a combobox.
EDIT
$scope.buildings gives
[Object, Object, Object]
$scope.buildings.building gives as below
Tidel
Ascendas
Sun-Tech
How can I do this? Am new to AngularJS. pls help me get through this.
Thanks in advance.
Upvotes: 0
Views: 64
Reputation: 786
<select>
<option value="">--Select--</option>
<option data-ng-repeat="l in buildings" value="{{l}}">{{l.building}}</option>
</select>
Where your display will contain building name and value would be object which you could use on server side, or it could be l.building only if you directly want building name as value of selected option
Here is the Plunker: https://plnkr.co/edit/tInZEPLXokb9NkqGk2so?p=preview
Upvotes: 1
Reputation: 21
You could have a autocomplete textbox that will have textbox for the input and dropdownlist for search reference.
Below is the link : http://csharpimp.blogspot.in/2016/03/angular-material-auto-complete.html
Upvotes: 0