Skip to content

Conversation

@Mattie112
Copy link

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

@EzequielMoroni
Copy link

Worked fine. Thanks!

@zeroxm
Copy link

zeroxm commented Apr 30, 2018

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.

@Mattie112
Copy link
Author

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

@zeroxm
Copy link

zeroxm commented Apr 30, 2018

@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?

@Mattie112
Copy link
Author

Mattie112 commented Apr 30, 2018

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"} ];

@zeroxm
Copy link

zeroxm commented Apr 30, 2018

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

@Mattie112
Copy link
Author

No probs! Have fun with it!

@gdejong
Copy link

gdejong commented Jul 30, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants