Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use same input-model to multiple multiselectors? #560

Open
swapnilanar opened this issue Jul 4, 2018 · 4 comments
Open

Use same input-model to multiple multiselectors? #560

swapnilanar opened this issue Jul 4, 2018 · 4 comments

Comments

@swapnilanar
Copy link

swapnilanar commented Jul 4, 2018

I am trying to use same input-model for multiple isteven-multi-select inside ng-repeat. But challenge I face is it binds to same input, so selecting any option from one dropdown selects that option in all isteven-multi-select

<div ng-repeat="d in dataList">
<div isteven-multi-select input-model="d.entities" output-model="d.selectedEntities" button-label="entityName" item-label="entityDisplayName" tick-property="ticked" max-labels="1">
</div>
</div>

@swapnilanar swapnilanar changed the title Multiple multiselectors Use same input-model to multiple multiselectors? Jul 4, 2018
@sterichards
Copy link

I'm having exactly the same problem on exactly the same day

I'm generating the isteven-multi-select inside an ng-repeat and I can't get them to separate. I've tried using a different output-model but that doesn't help

@isteven
Copy link
Owner

isteven commented Jul 4, 2018

Hi peeps,

That's the default behavior of Javascript: object is, by default, copied by reference (not deep copy). So any changes in one will affect all.

If you need it, you need to deep-copy the object you want manually before passing it into the directive.

@sterichards
Copy link

@isteven I had seen your comments from the other issues that mention this behaviour and it's solved using your previous suggestion of using angular.copy

Thank you,

@swapnilanar
Copy link
Author

@sterichards Yea, that's one workaround I had to do to complete functionality.
I had to create one dummy property in my dataList and bind that to input-model

HTML-
<div ng-repeat="d in dataList">
<div isteven-multi-select input-model="d.entities" output-model="d.selectedEntities" button-label="entityName" item-label="entityDisplayName" tick-property="ticked" max-labels="1">
</div>
</div>

JS-
$scope.dataList.forEach(function (d) { d.entities= angular.copy(data); })

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

No branches or pull requests

3 participants