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, 2020 in Angular by kartik
• 37,520 points
778 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, 2020 by Niroj
• 82,880 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, 2020 in Angular by Niroj
• 82,880 points
1,308 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, 2020 in Angular by Niroj
• 82,880 points
633 views
0 votes
1 answer

What is transclusion Scope in AngularJs?

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

answered Feb 6, 2020 in Angular by Niroj
• 82,880 points
823 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 Feb 11, 2020 in Angular by anonymous
• 82,880 points
544 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, 2020 in Web Development by Niroj
• 82,880 points

edited Jan 21, 2020 by Niroj 1,106 views
+1 vote
1 answer

What is css box module?

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

answered Jan 20, 2020 in Web Development by Niroj
• 82,880 points

edited Jan 21, 2020 by Niroj 1,182 views
0 votes
3 answers

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

display:none means that the tag in question will ...READ MORE

answered Dec 14, 2020 in Web Development by Gitika
• 65,890 points
119,621 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, 2020 in Web Development by Niroj
• 82,880 points

edited Jan 21, 2020 by Niroj 2,919 views
0 votes
1 answer
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP