What is shared scope in Directive

0 votes
Can anyone help me out with this tricky word name shared with scope(shared scope) with an example?
Feb 4, 2020 in Angular by anonymous
• 37,490 points
123 views

1 answer to this question.

0 votes

Assuming that you have knowledge on Scope( If not refer-Scope).

Taking you to the term called Shared Scope let's imagine i'm having markup related to Angularjs and that markup as you can see it has got a controller attached to that named as " sample" and that controller has couple of bindings here like a={{a}} and b={{b}} to be displayed from the scope which means this particular controller has some scope attached to it and imagine that particular scope is having member a=10 and b=20 those value are automatically to be displayed in a={{a}} and b={{b}}.

Now let us consider we are including a directive which is named as message and this message directive is to be instantiate by providing at the element level and takes mark-up from templateurl  and replace in element level.

if we have directive based element to be used inside controller element so,now which scope it will access??
By default it will access the scope which is define at the parent-level or controller level. so message element share the controller scope which is already defined by parent controller. This is called shared Scope.

answered Feb 4, 2020 by Niroj
• 82,580 points

Related Questions In Angular

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

What is inherited/child Scope in Controller?

hii, As you know(if not refer  ) that scope ...READ MORE

answered Feb 5, 2020 in Angular by Niroj
• 82,580 points
72 views
0 votes
1 answer

What is Scope Parameter in AngularJS?

Hey @kartik, Scope Parameter is a collection of ...READ MORE

answered Feb 5, 2020 in Angular by Niroj
• 82,580 points
189 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,580 points

edited Jan 21, 2020 by Niroj 206 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,580 points

edited Jan 21, 2020 by Niroj 218 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 13, 2020 in Web Development by Gitika
• 65,870 points
26,944 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,580 points

edited Jan 21, 2020 by Niroj 141 views
0 votes
1 answer
0 votes
1 answer

What is inherited/child scope in directive?

Hey kartik, As you use the term inheritance ...READ MORE

answered Feb 5, 2020 in Angular by Niroj
• 82,580 points
151 views