RootScope and Scope

RootScope and Sadha Scope

by Prasad Gavande

HTML

<!DOCTYPE html>
<html>

  <head>
    <link rel="stylesheet" href="style.css">
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
  
  </head>

  <body ng-app="myApp" >
    body controller {{color}}
    <div ng-controller="controller">
    div color  {{color}}
    </div>
    <script>
      var app=angular.module("myApp",[]);
      app.run(function($rootScope){
        $rootScope.color="red";
      });
      app.controller("controller", function($scope){
        $scope.color="blue";
      });
    </script>
  </body>

</html>