When utilizing ng-include, I face an issue where I am unable to change the controller by setting ng-controller inside the include. The controller seems to not be recognized by the include. However, it does work when I define the controller in the calling div that includes it.
For example:
Having an include like this:
<div ng-controller="baseController">
<div ng-include="other.html"></div>
</div>
The other.html is defined as follows:
<div ng-controller="subController">
<ul>
<li ng-repeat="address in addresses">
{{ address.name }}
</li>
</ul>
</div>
In this scenario, the addresses will not be displayed. But if I alter the code to this:
<div ng-controller="baseController" ng-controller="subController">
<div ng-include="other.html"></div>
</div>
The other.html is then defined as:
<div >
<ul>
<li ng-repeat="address in addresses">
{{ address.name }}
</li>
</ul>
</div>
Everything works perfectly and the addresses are successfully displayed.
Wondering why?
Best regards,
Jaap van der Kreeft