axel-zarate / js-custom-select

Custom auto-complete select box for AngularJS and Bootstrap
MIT License
68 stars 59 forks source link

How to get the entereed text which is entered in textbox while adding new item. #41

Closed sharathm89 closed 8 years ago

sharathm89 commented 8 years ago
<div custom-select="g for g in growable | filter: $searchTerm" ng-model="custom1" custom-select-options="growableOptions">
</div>

As shown in the above code which is found in the examples. How to retrieve text which is entered in textbox when adding a new item.

In the example code hardcoded item is being created rather which is entered. So how to get the entered text.


$scope.growable = ['Item 1', 'Item 2', 'Item 3'];
$scope.growableOptions = {
    addText: 'Add new item',
    onAdd: function () {
        var newItem = 'Item ' + ($scope.growable.length + 1);
        $scope.growable.push(newItem);
        return newItem;
    }
};
axel-zarate commented 8 years ago

It may sound silly but, as I haven't really used that feature I never thought of this simple thing. Anyway, it's fixed on this commit. Now, the text inside the search box is passed as the only parameter to the onAdd function.

sharathm1 commented 8 years ago

thanks