isteven / angular-multi-select

A multi select dropdown directive for AngularJS. Allows you to use HTML tags and CSS in the data. Requires only AngularJS and nothing else.
isteven.github.io/angular-multi-select
MIT License
1.08k stars 518 forks source link

Placeholder #485

Closed mjagyo closed 7 years ago

mjagyo commented 8 years ago

How can I add placeholder in button ?

inv

I just want to change the None Selected to something like "Select investments".

isteven commented 8 years ago

@pufffff ,

The setting is available in the manual. Try to read about "helper-elements"

langdonx commented 7 years ago

Edit, nevermind, I see requested it here: https://github.com/isteven/angular-multi-select/issues/424

@isteven helper-elements appear to only let you hide/show the Select All, Select None, and Reset buttons along with the Search input.

I think @pufffff was looking to change the drop down label. He can do this with translation="{ nothingSelected: 'Select Investments' }", but as soon as you select one, you either get values from the selected elements or simply (16) if you've exceeded the max.

I was looking to change this on a global level... and always have Select Investments (#) displayed where # is the number selected. It doesn't seem possible though, am I missing something?

isteven commented 7 years ago

@langdonx ,

Sorry for the late reply. In order to do that ("Select Investments (#)"), you'll need to modify the directive code. It's just a string modification, shouldn't be too hard if you have experience with directive.

youngzhao-xyz commented 7 years ago

@pufffff

This can be done using the translation attributes.

http://isteven.github.io/angular-multi-select/#/configs-options

You will need to add all define ALL five of the labels. For example:

$ctrl.customLabels = {
    selectAll: 'foo',
    selectNone: 'foo',
    reset: 'foo',
    search: 'Search investment name...',
    nothingSelected : 'Select investments'
};

CC @isteven

youngzhao-xyz commented 7 years ago

@langdonx

You could set the max-labels to 1.

For example there are 3 investments:

aa
bb
cc

So if you select aa and cc, the button will say aa, ...(2). I think this is similar to what you want, and from a UI point if view, aa, ...(2) is better and Select Investments (#), right?

Doc is there: http://isteven.github.io/angular-multi-select/#/configs-options

Look for max-labels

langdonx commented 7 years ago

@youngzhaosignifyd thanks, I already forked it though. My only option was "aa, ...", "Select Investments" or "(2)". Since most of the options in my list as 2-4 words (as long as the list itself), showing more than 1 wasn't a good idea. Simply showing "Select Investment" also didn't give the user any indication that anything was selected.

My commit to fix this is @ https://github.com/langdonx/angular-multi-select/commit/36c7666bf80a1cecde59ae4ce8b427185715e8f0 (mangled tabs/spaces, oops).