{"id":213,"date":"2017-03-22T11:56:17","date_gmt":"2017-03-22T11:56:17","guid":{"rendered":"http:\/\/codeinsightacademy.com\/blog\/?p=213"},"modified":"2017-05-12T05:23:13","modified_gmt":"2017-05-12T05:23:13","slug":"scope","status":"publish","type":"post","link":"https:\/\/codeinsightacademy.com\/blog\/angular-js\/scope\/","title":{"rendered":"Scope"},"content":{"rendered":"<p>&nbsp;<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"html\">&lt;DOCTYPE html&gt;\r\n&lt;html&gt;\r\n    &lt;head&gt;\r\n        &lt;meta CHARSET=\"UTF-8\"&gt;\r\n        &lt;script src=\"http:\/\/ajax.googleapis.com\/ajax\/libs\/angularjs\/1.4.8\/angular.min.js\"&gt;&lt;\/script&gt;\r\n    &lt;\/head&gt;\r\n    &lt;body ng-app=\"myApp\"&gt;\r\n        &lt;h2&gt;Scope&lt;\/h2&gt;\r\n        &lt;fieldset&gt;\r\n            &lt;legend&gt;\r\n                Circle\r\n            &lt;\/legend&gt;\r\n            &lt;div ng-controller=\"Circle\"&gt;\r\n                Radius = {{radius}} &lt;br\/&gt;\r\n                Diameter = {{diameter}} &lt;br\/&gt;\r\n                Area = {{area}} &lt;br\/&gt;\r\n                Circumference = {{circumference| number:2}} &lt;br\/&gt;\r\n            &lt;\/div&gt;\r\n            {{globalMessage}}\r\n        &lt;\/fieldset&gt;\r\n        &lt;fieldset&gt;\r\n            &lt;legend&gt;\r\n                Root Scope\r\n            &lt;\/legend&gt;\r\n            &lt;div&gt;\r\n                {{globalMessage}}\r\n            &lt;\/div&gt;\r\n        &lt;\/fieldset&gt;\r\n    &lt;\/body&gt;\r\n    &lt;script&gt;\r\n        var app = angular.module(\"myApp\", []);\r\n\r\n        app.run(function ($rootScope) {\r\n            $rootScope.globalMessage = \"I am from root Scope available throughout the module\";\r\n        });\r\n\r\n        app.controller(\"Circle\", function ($scope) {\r\n            $scope.radius = 5;\r\n            $scope.diameter = $scope.radius * 2;\r\n            $scope.area = 3.14 * $scope.radius * $scope.radius;\r\n            $scope.circumference = 2 * 3.14 * $scope.radius;\r\n        });\r\n    &lt;\/script&gt;\r\n&lt;\/html&gt;<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; &lt;DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;meta CHARSET=&#8221;UTF-8&#8243;&gt; &lt;script src=&#8221;http:\/\/ajax.googleapis.com\/ajax\/libs\/angularjs\/1.4.8\/angular.min.js&#8221;&gt;&lt;\/script&gt; &lt;\/head&gt; &lt;body ng-app=&#8221;myApp&#8221;&gt; &lt;h2&gt;Scope&lt;\/h2&gt; &lt;fieldset&gt; &lt;legend&gt; Circle &lt;\/legend&gt; &lt;div ng-controller=&#8221;Circle&#8221;&gt; Radius = {{radius}} &lt;br\/&gt; Diameter = {{diameter}} &lt;br\/&gt; Area = {{area}} &lt;br\/&gt; Circumference = {{circumference| number:2}} &lt;br\/&gt; &lt;\/div&gt; {{globalMessage}} &lt;\/fieldset&gt; &lt;fieldset&gt; &lt;legend&gt; Root Scope &lt;\/legend&gt; &lt;div&gt; {{globalMessage}} &lt;\/div&gt; &lt;\/fieldset&gt; &lt;\/body&gt; &lt;script&gt; var app = angular.module(&#8220;myApp&#8221;, []); [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"quote","meta":[],"categories":[6],"tags":[],"_links":{"self":[{"href":"https:\/\/codeinsightacademy.com\/blog\/wp-json\/wp\/v2\/posts\/213"}],"collection":[{"href":"https:\/\/codeinsightacademy.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codeinsightacademy.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codeinsightacademy.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codeinsightacademy.com\/blog\/wp-json\/wp\/v2\/comments?post=213"}],"version-history":[{"count":2,"href":"https:\/\/codeinsightacademy.com\/blog\/wp-json\/wp\/v2\/posts\/213\/revisions"}],"predecessor-version":[{"id":259,"href":"https:\/\/codeinsightacademy.com\/blog\/wp-json\/wp\/v2\/posts\/213\/revisions\/259"}],"wp:attachment":[{"href":"https:\/\/codeinsightacademy.com\/blog\/wp-json\/wp\/v2\/media?parent=213"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codeinsightacademy.com\/blog\/wp-json\/wp\/v2\/categories?post=213"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codeinsightacademy.com\/blog\/wp-json\/wp\/v2\/tags?post=213"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}