I would like ChildCtrl
to be initialized only when the button above it is clicked. how is that possible?
<div ng-controller="ParentCtrl">
<button>CLICK TO INIT CHILD CTRL</button>
<div class="child-container">
<div ng-controller="ChildCtrl" ng-include="'templates/child.html'" />
</div>
</div>
That is easy, use ng-if:
ng-if
directive does not load the DOM unless the expression istrue
.