Skip to content

Single selection drop-down unable to reset the values in nya bootstrap select in angular 1.5 #182

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

Open
shivaprakashboss opened this issue Feb 22, 2018 · 19 comments

Comments

@shivaprakashboss
Copy link

I am using nya bootstrap select for dropdowns when I click reset to bring back the values from the DB values are not resetting on UI .The old value getting retained on screen even though in controller the values are fetched from DB. How to tackle this ? Please help we badly need this

@shivaprakashboss
Copy link
Author

I even tried with setting the variable to undefined or "" or null or {} but no luck this happens for single selection but multiple it is working fine.

@shivaprakashboss
Copy link
Author

On clicking the reset button ,In the controller ,scope variable have the new values that is not reflecting on the UI where it has previous selected values.this is not happening on first time loading of page where I fetch the same data from database.

@lordfriend
Copy link
Owner

No built-in reset (unselect) in single select mode. You have to reset your model to undefined or null.

@shivaprakashboss
Copy link
Author

I have reset the model to undefined as well as null but there is no expected behaviour. Say $scope.users={} or $scope.users=null I didn't see the value getting reset. Please help

@shivaprakashboss
Copy link
Author

Even if I reset to some other value also it is not resetting to that value let me know what I am missing.

@MrWook
Copy link
Contributor

MrWook commented Feb 23, 2018

works fine for me

@shivaprakashboss
Copy link
Author

shivaprakashboss commented Feb 23, 2018

could you please share the example how you do it and share the nya.bootstrap.select.js file. today morning i checked the reset with latest nya.bootstrap.select.js file. reset is working fine when we change the value in the controller but after that if i change the items in the dropdown ,model not getting updated.Please help

@MrWook
Copy link
Contributor

MrWook commented Feb 23, 2018

Click on my text in the previous comment, it is a link, it glows blue.

But to reset the model to undefined and change the present data is a different thing.
Try to add deep-watch="true" on the same element as "nya-bs-option"

@shivaprakashboss
Copy link
Author

i have added deep-watch and sorry angular version is 1.3 not 1.5 please help

@shivaprakashboss
Copy link
Author

is the version mismatch makes this behave indifferent ?

@shivaprakashboss
Copy link
Author

i have gone through your link and it is working as expected

@MrWook
Copy link
Contributor

MrWook commented Feb 23, 2018

I added a complete data set change and a single data change, also the example use angular 1.3 now and everything is working like it should be.

@shivaprakashboss
Copy link
Author

somehow it is not working in our project. i have tried to implement as like in the link but unable to succeed.

@shivaprakashboss
Copy link
Author

what might be the issue why i am not able to implement the feature which is already existing.

@lordfriend
Copy link
Owner

Maybe some directive like ng-if or ng-repeat creates a child scope which overrides your name. It's suggested to use controllerAs instead of directly manipulate $scope.

@shivaprakashboss
Copy link
Author

sir give me an example how i should use $scope or controller.

@shivaprakashboss
Copy link
Author

where i should use this controllerAs ?

@lordfriend
Copy link
Owner

It really depends on your application design (for example if you set up your controller in ngRoute or ui-router, you should config controllerAs at route config)
To be simple, a controllerAs alias can be treated as a model in $scope which all other model is its property.
Here is an article talk about this topic.
https://johnpapa.net/angularjss-controller-as-and-the-vm-variable/

@shivaprakashboss
Copy link
Author

Ok I will try and update the behaviour thanks.

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