What is the relation between transclusion scope and directive shared scope in AngularJS ?

0 votes
I know about Directive scope but i don't have any idea about Directive shared scope and what's the relationship with transclusion scope?
Feb 6 in Angular by kartik
• 1,910 points
15 views

1 answer to this question.

0 votes

hey,

Let me help you out with the following piece of code assuming that we have a final code after being transclusion:

(If you want to know how this  sample final code is achieved you can first check it out the link- Transclusion)

 <div ng-controller='emp'>
           Some  message from controller
                <div message>
                             This is from msg template
                             <div>This is inner message</div>                               
                </div>
  </div>

From above it is clear that there is only one controller named emp and directive named message in it which has a transclude text embed in it.

So, first the parent scope i.e controller scope is made available through the entire cycle and then we have directive scope which is named as directive shared scope because the directive scope shared its parent scope. so, all the data available in controller scope is also available to directive scope.

Now, we were having a transclusion scope which is having new instance independent of its parent scope and this particular instance is inherited from its parent scope or can say the parent of the directive scope. As it inherit the controller scope, so all data member is available in the transclusion scope and another special things to be remember when an new instance of transclusion is created there is always $parent member is associated with the transclusion scope along with parent's data memeber. In this case $parent is going to refer the parent controller i.e the controller scope.

The whole scenario from the above explanation can be depict from the diagram attached below.

answered Feb 6 by Niroj
• 3,230 points

Related Questions In Angular

0 votes
1 answer

What is shared scope(in Directive)?

Assuming that you have knowledge on Scope( ...READ MORE

answered Feb 4 in Angular by Niroj
• 3,230 points
16 views
0 votes
1 answer

What is the difference between Call back transclusion function and no call back transclusion function?

Hey,    There is no difference between clone linking and ...READ MORE

answered Feb 5 in Angular by Niroj
• 3,230 points
25 views
0 votes
1 answer

What is transclusion Scope in AngularJs?

hey @kartik, Let me start with What is ...READ MORE

answered Feb 6 in Angular by Niroj
• 3,230 points
11 views
0 votes
1 answer

What is the service that is used to configure the UI-Router and ngRoute in AngularJs?

Routing comes into play whenever you want ...READ MORE

answered 6 days ago in Angular by anonymous
• 3,230 points
12 views
+1 vote
1 answer

What is the relationship between angularjs Scope with controller/view?

Let us consider the below block: <div ng-controller="emp"> ...READ MORE

answered Jan 20 in Web Development by Niroj
• 3,230 points

edited Jan 21 by Niroj 29 views
+1 vote
1 answer

What is css box module?

Hey, All the element present in html follows ...READ MORE

answered Jan 20 in Web Development by Niroj
• 3,230 points

edited Jan 21 by Niroj 30 views
0 votes
1 answer

Explain the difference between visibility:hidden; and display:none?

hii, visibility:hidden; and display:none are totally different used ...READ MORE

answered Jan 20 in Web Development by Niroj
• 3,230 points
57 views
+1 vote
1 answer

How to access the Angularjs scope of a particular html element from our console?

Hello, You should follow the below steps:-- 1.Compile and ...READ MORE

answered Jan 21 in Web Development by Niroj
• 3,230 points

edited Jan 21 by Niroj 31 views
0 votes
1 answer
0 votes
1 answer