user6004404
user6004404

Reputation:

Angular ng-include and specifying controllers

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?

Upvotes: 0

Views: 1003

Answers (3)

rittam
rittam

Reputation: 318

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

Upvotes: 0

Yogesh
Yogesh

Reputation: 1585

If including it inside element which has mainCtrl then yes it will automatically share parent scope (mainCtrl), otherwise no.

Upvotes: 1

Foker
Foker

Reputation: 1011

mainCtrl and it's scope will be also available in your included part.

Upvotes: 0

Related Questions