vishnu vishnu - 5 months ago 123
AngularJS Question

getting 'values.map is not a function' error using angularstrap selectbox

I am using angular strap select box for displaying the options,
But i am not getting the options, error saying:


values.map is not a function


How do i loop the options using angular strap select box

$scope.info = {"1":"1 - Cash","2":"2 - Clearing"}
<button type="button" class="btn btn-default" data-ng-model="info.value" ng-options="id as value for (id, value) in info" bs-select>
Action
<span class="caret"></span>
</button>

Answer

Apparently AngularStrap does not implement full ngOptions support. Looking through source code it seems that their select expects (see source) and array as values collection. I would recommend to use array data structure, which is anyway looks more convenient in this case:

$scope.info = [{id: 1, text: "1 - Cash"}, {id: 2, text: "2 - Clearing"}];

and HTML:

<button type="button" class="btn btn-default" 
        data-ng-model="info.value" 
        ng-options="value.id as value.text for value in info" bs-select>
    Action <span class="caret"></span>
</button>