Suppose I have index.html which has mainCtrl as its controller. If I use an ng-include in index.html to include partial html code that is saved on a separate page, does the included page have the mainCtrl or do I need to specify it again on that page?
3 Answers
mainCtrl and it's scope will be also available in your included part.
2 Comments
Wagner Danda da Silva Filho
Not always true. If the ng-include is not inside an element referencing the controller, then the controller won't be available in the included template.
Foker
@wdanda "Suppose I have index.html which has mainCtrl as its controller. If I use an ng-include in index.html to include partial html code.." in index.html , that has mainCtrl as it's controller
ngInclude Directive
Directive Info
This directive creates new scope.
You can also find a good example in the below link.
Source: https://docs.angularjs.org/api/ng/directive/ngInclude