angular-bootstrap-multiselect icon indicating copy to clipboard operation
angular-bootstrap-multiselect copied to clipboard

Added option to preselect an item

Open Mattie112 opened this issue 8 years ago • 8 comments

By filling the $scope.resolvedOptions in both methods we can "preselect" some items.

example:

// You can add this in your app.js
$scope.options = [ {id: 1, foo: "bar"}, {id: 2, bar: "foo"} ];
$scope.selection = [ {id: 1, foo: "bar"} ];

When you load your webpage the item with id 1 is already selected

Mattie112 avatar Nov 27 '17 14:11 Mattie112

Worked fine. Thanks!

EzequielMoroni avatar Mar 10 '18 19:03 EzequielMoroni

Was this merged on master?

I need this so all options come pre-selected and the user filters then out, instead of selecting then.

May be an odd behavior, I know, but it's what was requested.

zeroxm avatar Apr 30 '18 16:04 zeroxm

As far as I know this is not merged, but feel free to my fork.

Mattie112 avatar Apr 30 '18 17:04 Mattie112

@Mattie112 , could you help me on how to use this?

I have someting like this:

<multiselect ng-model="filtro.clientes" 
                 options="clientes" 
                 id-prop="id" 
                 display-prop="nome"
                 name="cliente"
                 labels="labelsClientes"
                 show-select-all="true"
                 required>```

How do I set all options as selected?

zeroxm avatar Apr 30 '18 17:04 zeroxm

Simply set it in your JS code :)

<multiselect ng-model="selection" 
                 options="options" >
// You can add this in your app.js
$scope.options = [ {id: 1, foo: "bar"}, {id: 2, bar: "foo"} ];
$scope.selection = [ {id: 1, foo: "bar"} ];

Mattie112 avatar Apr 30 '18 17:04 Mattie112

Oh yup, it's simple, Thanks! You're awesome!

zeroxm avatar Apr 30 '18 17:04 zeroxm

No probs! Have fun with it!

Mattie112 avatar Apr 30 '18 17:04 Mattie112

I'd love to use this feature, any updates on merging this in the master @bentorfs?

gdejong avatar Jul 30 '18 09:07 gdejong