Share the post "Creating Cascading Dropdown Select In Angular JS"
Before Angular JS, my idea of a cascading dropdown select would be to some dropdown components in my HTML page and loading the children based on its parent.
With Angular JS, I would recommend you avoid this style. Why create so 2 dropdown controls when you can have only one and show the options in a tree like structure together with its parent?
If your hierarchy involves more than 2 levels, you can easily create a directive for it.
For simplicity’s sake, rather than showing 2 dropdown controls and changing the second dropdown based on the parent chosen in the first dropdown, you can use the “group by” keyword in the ng-option attribute of the SELECT tag.
Think of “group by” the same way you do in SQL. Pretty easy, right?
A sample code would be:
|
1 |
ng-option="bt.id_of_child as bt.child_name group by bt.parent_name for bt in batchTypes" |



