After referencing the "How to create directives that communicate" section in the angularJS guide, I decided to apply that concept to develop a navigable form.
The challenge arose when attempting to access the main scope to input data from the form fields due to directive namespace isolation. The workaround involved utilizing numerous $parent references:
<div id="showfoo">Foo = {{foo}}</div>
<form-tabs>
<form-tab>
<input ng-model="$parent.$parent.$parent.$parent.foo" />
</form-tab>
<form-tab>
<input ng-model="$parent.$parent.$parent.$parent.foo" />
</form-tab>
<form-tab>
<input ng-model="$parent.$parent.$parent.$parent.foo" />
</form-tab>
</form-tabs>
This nesting structure of four levels is a consequence of creating child scopes for each transclude and isolate scope.
The primary query remains - how can this convoluted setup be avoided? Ideally, a straightforward <input ng-model="foo">
should suffice in updating the div#showfoo
.
To view the complete code, visit: http://plnkr.co/edit/jgD7a6W53518qpyLNUcx?p=preview