0

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.

2 Answers 2

1
 <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

Sign up to request clarification or add additional context in comments.

5 Comments

I am getting undefined in combo box. buildings has list of objects. Inside for loop in controller, buildings.building gives me building name. similarly how can I do this in combo box in html?
Can you post a snapshot of buildings.building object so it would help more in answering?
now am getting the --Select-- and the last value in the list, that is Sun-Tech. I want all three along with Select. :(
I have updated the answer please check plunker link also @Kaushi
Welcome :) @Kaushi
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.