问题描述:

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.

网友答案:
 <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

网友答案:

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

相关阅读:
Top