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

ngModelAttrs - options-disabled is not disabling the select elements #78

Open
hrishi1183 opened this issue Sep 19, 2015 · 4 comments
Open

Comments

@hrishi1183
Copy link
Contributor

i am trying to disable the select options based on the selected group so that same group should not be selectable in further dropdowns.. but ngModelAttrs is not working as expected with options-disabled

belows is the jsbin which shows the issue
http://jsbin.com/duzuce/edit?js,output

disabledGroups already holds the "Vehicle Loans" group which mean by default Vehicle Loans should be disabled in all the three dropdown which is not the case.. and based on the selection in first select.. corresponding groupd should get disabled in further choice lists

Any help would be appreciated

@kentcdodds
Copy link
Member

Sorry, life's crazy busy for me right now (new baby in the house). I don't
have time to help you right now. Could you please follow the instructions
here to get help? http://help.angular-formly.com

Good luck!

On Fri, Sep 18, 2015, 9:29 PM Hrishikesh Moundekar notifications@github.com
wrote:

i am trying to disable the select options based on the selected group so
that same group should not be selectable in further dropdowns.. but
ngModelAttrs is not working as expected with options-disabled

belows is the jsbin which shows the issue
http://jsbin.com/duzuce/edit?js,output

disabledGroups already holds the "Vehicle Loans" group which mean by
default Vehicle Loans should be disabled in all the three dropdown which is
not the case.. and based on the selection in first select.. corresponding
groupd should get disabled in further choice lists

Any help would be appreciated


Reply to this email directly or view it on GitHub
#78.

@ckniffen
Copy link
Member

@hrishi1183 All that the select type from angular-formly-templates-bootstrap does is perform a small wrapper around creating a element with ngOptions set on it. It seems the current configuration does not handle disabling any field much less a whole group at once. Looking into the ngOptions documentation (https://docs.angularjs.org/api/ng/directive/ngOptions) it seems that individual options can be disabled. The following code can be updated here https://github.com/formly-js/angular-formly-templates-bootstrap/blob/5ecf62aa1191488222cc9ae584390a8803757625/src/types/select.js#L13 in the angular-formly-templates-bootstrap repo. PRs welcome.

@hrishi1183
Copy link
Contributor Author

Below is the working jsbin for my issue..
http://jsbin.com/vevaka/edit?js,output
current approach uses $rootScope to hold the disabled group as i was unable to update disableGroup of second select while selecting the value in first dropdown(i.e. onChange event)

@kentcdodds
Copy link
Member

I only had a minute to look at this, so I'm not certain right now what the issue is, but my first impression is that you have got to switch from storing all of this in the $rootScope and store it in a factory instead. It will make your life infinitely easier.

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