This is because ngSwitch
creates new scope. (If you look at the $$childHead
value of the scope that get's console.log
'd, you can see theForm
inside it. This is the ngSwitch
scope).
If the form will always be the same name, you can simply put the ngSwitch
es inside the form:
<form name="theForm">
<div ng-switch on="type">
<div ng-switch-when="1">
<label>Form 1</label>
<input type="text"/>
</div>
<div ng-switch-when="2">
<label>Form 2</label>
<input type="text"/>
</div>
</div>
</form>