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

+1 vote
Want to know about what happens if ng-controller is defined without any reference of controller and vice-versa.
Jan 20 in Web Development by kartik
• 2,020 points
37 views

1 answer to this question.

0 votes

Let us consider the below block:

<div ng-controller="emp">  //emp is the controller name

.........(View Part)

</div>

When above block is compiled, it tries to create boundary/context which is stored in some browser memory that contains some data in block which is not shown to user.

The boundary/context is then attached to ng-controller="emp" block. So the boundary has the direct accessed by the block.

This boundary/context is called as scope. So when you mention emp you are saying to create new controller instance along with scope being merged. Now,Scope acts as a mediator between controller instance and view(block).

Now,finally if view wants to send data to controller then it send through scope and vice-versa.

Explanation of above is attached for your reference:

Image shows the relationship of scope with controller and view

answered Jan 20 by Niroj
• 3,580 points

edited Jan 21 by Niroj

Related Questions In Web Development

0 votes
1 answer

What is the difference between span and div?

The div should be used to wrap sections of ...READ MORE

answered Jan 16 in Web Development by Niraj

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

edited Jan 21 by Niroj 36 views
0 votes
1 answer

What is data binding in AngularJS?

Data binding is synchronization of data between the ...READ MORE

answered Jan 23 in Web Development by Niroj
• 3,580 points
26 views
0 votes
1 answer

What does cors means in Angularjs and what the use of it?

CORS is Cross Origin Resource Sharing which means you ...READ MORE

answered Jan 29 in Web Development by kartik
• 2,020 points
46 views
0 votes
1 answer

How can we avoid my php form from hacking?

Hii @kartik, If you want to know php ...READ MORE

answered Feb 13 in PHP by Niroj
• 3,580 points
20 views
0 votes
1 answer

What is a Cookie? How to create Cookies With PHP?

A cookie is often used to identify ...READ MORE

answered Feb 13 in PHP by Niroj
• 3,580 points
23 views
0 votes
1 answer

How to shrink Navigation menu or bar on Scroll?

Hey, You can follow the steps below in ...READ MORE

answered Feb 19 in PHP by varun
17 views
0 votes
0 answers
+1 vote
1 answer

What are the different ways of using angularjs scope?

Hey!! basically there the three ways of using ...READ MORE

answered Jan 21 in Web Development by Niroj
• 3,580 points
28 views
+1 vote
5 answers

What is the difference between web design and web development?

A designer designs the web pages and ...READ MORE

answered Jan 22 in Web Development by Niroj
• 3,580 points
47 views