-
Notifications
You must be signed in to change notification settings - Fork 64
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
The selectedItems input is never used #85
Comments
Hey there! Yes that is correct and also more or less by design. That input is not meant to be used to pass in an array of items that are selected. There are other APIs that you can use to programatically select items. The input exists so that we can use a two-way binding on the select container, e.g. Does that make sense? |
"Two-way data binding" means that the binding is bidirectional: from the parent component to the child and vice-versa. For this reason in Angular templates is indicated with the "banana box" syntax, remarking that the variable passed is used both as an input and an output. Since the select container-component is not using the input, i don't think it can be called two-way data binding, but it can be considered as an output, that is the same of the Moreover, the documentation says that |
So this is only output, not input. |
Yea, you are right. It's not a true two-way data binding in the sense that whatever you pass in is also used internally. Changing this is definitely a breaking change and I am hesitating to make it a true way data binding. I'd rather not use that cause I am personally against bi-directional bindings because it's harder to keep track of changes and I prefer a uni-directional data flow. I only added support for the "banana in the box" syntax to make it easier to bind a model to select item changes, so that you don't have to assign this yourself, e.g. If you want to select items programatically there's API on the select container. |
Hi, This is a really weard behavior. Most Angular 2+ developers will expect a true 2-way binding when seing something like I understand that you don't like 2-way binding. But it's harder to keep track of changes when you see something that is like 2-way binding without being it... As that change is a break change, could it not be an option to passe to Maybe something like : DragToSelectModule.forRoot({
selectedItemsTwoWayDataBinding: true
}); |
I made some changes to let the possibility to have two-way binding : What do you think ? |
@vincentjdc Yes I like the idea of using the config to enable this. I see if I can get this in soon. |
The
selectedItems
input is not used inside thedts-select-container
component. If the user pass an array with some items already selected, they will not be considered by the component.This is an example: https://stackblitz.com/edit/ngx-drag-to-select-yqxr4t
In the HomeComponent I'm passing an array with some values:
but they are not marked as selected in the component. Moreover, if I use the "banana box" syntax, the component will clear the selected array and delete the values that are present in the passed array
The text was updated successfully, but these errors were encountered: