Search code examples
angularjsangularjs-ng-repeatangularjs-ng-optionsangularjs-select

Angularjs listbox control with single selection


I'm just looking for a listbox with single selection so that each item can be selected from the listbox.

But unable make it to single selection using the below code after make it to multiple = false.

Can any body suggest me the code here.

$http({
                method: 'GET',
                url: 'http://xxxx/api/controller/GetAllItems',
                params: { Pt_Id: 'US' }
            }).then(function successCallback(response) {
                //  alert(response.data);
                $scope.items = response.data;
            }, function errorCallback(response) {
                // alert(response);
            });

<select ng-model="itm" multiple="false" size="10" ng-options="itm.ITEM_ID for itm in items"></select>

Solution

  • Remove multiple="false" in the select then you can make single selection

    <select ng-model="itm" size="10" ng-options="itm.ITEM_ID for itm in items"></select>