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

How do I: create fields that depends on each other #45

Closed
schadedk opened this issue Nov 13, 2013 · 9 comments
Closed

How do I: create fields that depends on each other #45

schadedk opened this issue Nov 13, 2013 · 9 comments
Labels

Comments

@schadedk
Copy link

Hi,

I have two select local fields, were the content of one of them, should depend on the value of the other.

Eg: select 1: "Letters, "Digits"
Select 2: should contain "A","B","C" when select 1 is "Letters"
Select 2: should contain "1,"2","3" when select 1 is "Digits".

Is that possible to accomplish?

@schadedk
Copy link
Author

I don't know if this is the right way to do it, I did accomplish it, and this is what I did:

<span editable-select="select1" e-class="select-field" onshow="showingSelect1(this)....>
<span editable-select="select2" e-class="select-field" e-ng-options="s.Id as s.Text for s in select2data" ...>

On my controller the showingSelect method did the following:

$scope.showingSelect = function (selectDirective) {

selectDirective.$watch('$data', function () {
<<when data is change change the value for select2data >>
});
};

@vitalets
Copy link
Owner

@schadedk you solution works but I think the more right way not to watch hidden $data variable, you may watch
directly value of first select.
Please have a look:
http://jsfiddle.net/NfPcH/214/

@schadedk
Copy link
Author

Thanks!

Your solution is much nicer, and is just what I was looking for.

Thank you for your help!

@vitalets
Copy link
Owner

You are welcome :)

@ghost
Copy link

ghost commented Oct 6, 2014

Hi @vitalets ,

I am working on dates with the same technique.

How can I achieve the same if I have multiple fields (ng-repeat) ?

Scenario: I have month and day fields. Number of days in a month is displayed when the month is selected.. I have months and days inside ng-repeat.

Regards,
Ajju

@pavi95
Copy link

pavi95 commented Apr 17, 2017

I am working on dynamic drop downs. Tried with your possible solutions but not able to achieve.. Please help me out!! @vitalets @schadedk

@ckosloski
Copy link
Contributor

@pavi95 can you provide a jsfiddle/plunkr showing your issue?

@ghost
Copy link

ghost commented Apr 17, 2017 via email

@pavi95
Copy link

pavi95 commented Apr 18, 2017

@ckosloski @ajjublr Thanks for your valuable time man. I found this fiddle.. It helps me out.. https://jsfiddle.net/32kzsvve/1/ it may help others

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants