How to show a list of data


#1

Hi this is the coding I have so far… I have a RESTful WCF service and want to populate a select option with a list of data. am I doing it right?

    <label class="item item-input item-select">
            <div class="input-label">
                Lightsaber
            </div>   
            <select ng-model="documents">
                <option ng-repeat="item in documents" value="{{item.id}}">{{item.id}}</option>
            </select>
        </label>

.controller('DashCtrl', function($scope, $http) {
    $http.get("http://localhost:15021/Service1.svc/getAllTrucks")
            .success(function(data) {

                var obj = data;
                var ar = [];

                angular.forEach(obj, function(index, element) {

                    angular.forEach(index, function(indexN, elementN) {
                        ar = {id: indexN.QuoteID, quotenum: indexN.QuoteNumber};

                        console.log(ar);
                    });

                    $scope.documents = ar;

                });

                console.log(data);
            })
            .error(function(data) {
                console.log("failure");
            });

#2

you are connecting the ng-model to the documents-list in your template… so you are overwriting your list


#3

O thanks, but still removing it changes nothing… it shows both the items but not the text values? @bengtler