“$scope” is an object instance of a controller. “$scope” object
instance get’s created when “ng-controller” directive is encountered.
For example in the below code snippet we have two controllers “Function1” and “Function2”. In both the controllers we have a “ControllerName” variable.
Now once the instances are created, below is a graphical
representation of the same. So the “DIV1” HTML UI is binded with
“function1” $scope instance and the “DIV2” HTML UI is binded with
“function2” $scope instance. In other words now anything changes in the
$scope object the UI will be updated and any change in the UI will
update the respective $scope object.
For example in the below code snippet we have two controllers “Function1” and “Function2”. In both the controllers we have a “ControllerName” variable.
function Function1($scope)
{
$scope.ControllerName = "Function1";
}
function Function2($scope)
{
$scope.ControllerName = "Function2";
}
Now to attach the above controllers to HTML UI we need to use
“ng-controller” directive. For instance you can see in the below code
snippet how “ng-controller” directive attaches “function1” with “div1”
tag and “function2” with “div2” tag.<div id=”div1” ng-controller="Function1"> Instance of {{ControllerName}} created </div> <div id=”div2” ng-controller="Function2"> Instance of {{ControllerName}} created </div>So this is what happens internally. Once the HTML DOM is created Angular parser starts running on the DOM and following are the sequence of events:-
- The parser first finds “ng-controller” directive which is pointing to “Function1”. He creates a new instance of “$scope” object and connects to the “div1” UI.
- The parser then starts moving ahead and encounters one more “ng-controller” directive which is pointing to “Function2”. He creates a new instance of “$scope” object and connects to the “div2” UI.


Hello Sumitrke,
ReplyDeleteVery Useful blog to learn angularjs. Thanks for the FAQs, It gave confidence to attend Interviews.
Good Presentation. Thanks for the useful blog. Keep updating.If you want to learn Angular js course in online, please visit below site.
ReplyDeleteAngular js online training
angular js online course
angular js online training in Hyderabad
angular js online training in Bangalore
angular js online training in Chennai
This is a nice article here with some useful tips for those who are not used-to comment that frequently. Thanks for this helpful information I agree with all points you have given to us. I will follow all of them.
ReplyDeleteClick here:
angularjs4 Training in Chennai
Click here:
angularjs5 Training in Chennai
Click here:
Selenium Training in Chennai
Click here:
Aws Training in Chennai
It would have been the happiest moment for you,I mean if we have been waiting for something to happen and when it happens we forgot all hardwork and wait for getting that happened.
ReplyDeleteClick here:
Microsoft azure training in bangalore
Click here:
Microsoft azure training in pune
Nice post. By reading your blog, i get inspired and this provides some useful information. Thank you for posting this exclusive post for our vision.
ReplyDeleteBlueprism training in Chennai
Blueprism training in Bangalore
Blueprism training in Pune
Blueprism online training
Blueprism training in tambaram
This looks absolutely perfect. All these tiny details are made with lot of background knowledge. I like it a lot.
ReplyDeletejava training in chennai | java training in bangalore
java interview questions and answers | core java interview questions and answers
Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging.
ReplyDeleteData Science course in Chennai | Data science course in bangalore
Data science course in pune | Data science online course
Data Science Interview questions and answers | Python course in Kalyan nagar
I’m thoroughly enjoying your blog. I as well as an aspiring blog writer, but I’m still new to the whole thing. Do you have any recommendations for newbie blog writers? I’d appreciate it.
ReplyDeletenebosh course in chennai
Your good knowledge and kindness in playing with all the pieces were very useful. I don’t know what I would have done if I had not encountered such a step like this.
ReplyDeleteinformatica mdm online training
apache spark online training
apache spark online training
devops online training
aws online training
Some us know all relating to the compelling medium you present powerful steps on this blog and therefore strongly encourage contribution from other ones on this subject while our own child is truly discovering a great deal. Have fun with the remaining portion of the year.
ReplyDeleteMicrosoft Azure online training
Selenium online training
Java online training
Python online training
uipath online training