bentorfs / angular-bootstrap-multiselect

Native angularJS custom form element
http://bentorfs.github.io/angular-bootstrap-multiselect/
MIT License
79 stars 111 forks source link

QUESTION - Change button text instead of "Select" #46

Closed oiacrasec closed 7 years ago

oiacrasec commented 7 years ago

Hello, how can i easily change the button text to something i want?

oiacrasec commented 7 years ago

After search throught the code just pass the attribute: placeholder="Your Placeholder" labels="vm.labels"

Controller:

        vm.labels = {
            'itemsSelected': 'text you want',
            'search': 'Search...'
        };
sanmishra7 commented 7 years ago

If my project contains 3 drop downs and I want to have a different button text instead of "Select" for each of them. How can I do it?

oiacrasec commented 7 years ago

I think the easiest way is create 3 variable labels like:

<multiselect id="sel2-{{ $index }}" ng-model="conta.rateio.racas"
                                                     placeholder="Selecione" 
                                                     labels="vm.labels" <<<<<<<<<<<<< **HERE**
                                                     options="vm.racas" class="child"
                                                     id-prop="id" display-prop="nome" show-search="true"></multiselect>
vm.labels = {
            'itemsSelected': 'opções',
            'search': 'Pesquisar...'
        };

You can create a vm.labels base only with the value for itemsSelected and extend in another variable the search value, like:

vm.labels2 = angular.extend(destination_object, source)

More details: https://docs.angularjs.org/api/ng/function/angular.extend

And to finish, just pass to your second multselect the vm.labels2

bentorfs commented 7 years ago

You can use the labels attribute: https://bentorfs.github.io/angular-bootstrap-multiselect/#example-labels