Angularjs scope vs rootScope objects Example

Angularjs scope vs rootScope objects Example

In this Post We Will Explain About is Angularjs scope vs rootScope objects Example With Example and Demo.Welcome on infinityknow.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to AngularJS $scope and $rootScope Service – $rootScope Example

In this post we will show you Best way to implement Difference between $scope and $rootScope Example, hear for Difference Between $scope And $rootscope In AngularJSwith Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

“$rootScope” object is a parent means roots object of all “$scope” angularjs objects created in a web-application page. $scope object is created with simple ng-controller while $rootscope object is created with ng-app directive .and as well as …

READ :  Laravel One to One Eloquent Relationship Example

$rootScope object is available globally type init, no matter what any controller we are in, whereas $scope object is only available to the simple uses current controller and call the it’s sub children.

<!DOCTYPE html>
<html ng-app="liveApp"> 
<head>
  <title>Angularjs $rootScope object and $scope object</title>
  <script src="/1.2.16/angular.js"></script>
</head>
<body>
	<h1></h1>
  <p>Big products is {{ product }}.</p>
  <div ng-controller="liveproductCtrl">
    <p>The Main is {{ product }}.</p>
  </div>
  <div ng-controller="itemCtrl">
    <p>The Sub is {{ product }}.</p>
  </div>
  
  <script type="text/javascript">
    var liveApp = angular.module('liveApp', []).run(function($rootScope) {
      $rootScope.product = 'laptop';
    });
    liveApp.controller('liveproductCtrl', function($scope) {
      $scope.product = 'computer';
    });
    liveApp.controller('itemCtrl', function($scope) {
    });
  </script>
</body>
</html>

Example

I hope you have Got What is difference between scope and scope with Example And how it works.I would Like to have FeadBack From My Blog(infinityknow.com) readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article(infinityknow.com) Are Most Always Welcome.

READ :  AngularJS filter capitalize First letter of Every word

Add a Comment

Your email address will not be published. Required fields are marked *