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:
ng-option="bt.id_of_child as bt.child_name group by bt.parent_name for bt in batchTypes"
Being new to iOS after the Swift programming language was announced, it was a pain for me to find a fix to why the ScrollView always places an extra space at the top of the child view even though I already placed constraints.
I mean, that is what constraints are for, right? Check the image below. The ScrollView has a background color that looks pink and orange while its child View has a white background.
See the extra space at the top? I tried to set combinations of alignment and spacing constraints to no avail. I wasted almost a half day for this till I decided to try my luck looking in Google searches for a solution.
And the solution is?
Click your ViewController in the tree list on the left
Select the Attribute Inspector
Under the View Controller area, go to the label that says Layout : Adjust Scroll View Insets
Uncheck that and recompile.
Now the extra top space will disappear.
Since I am still new to iOS, I do not understand the purpose of this option. There are constraints in the first place so what is this for? Regardless, to avoid this problem, this is the only solution that works without doing any coding.
This typically works in iOS7 and later. However, I read that in iOS6 it still leaves a gap. I have not tested this but you could try this option that user Anooj VM provided in the Stack Overflow forum.
The fix is to implement within the viewDidLoad() by adding this line of code: