AngularJS: Bootcamp - Learn The Basics of Ruby Programming in 2 Weeks! (FREE Bonus, AngularJS 2 Programming By Example) by David Maxwell

AngularJS: Bootcamp - Learn The Basics of Ruby Programming in 2 Weeks! (FREE Bonus, AngularJS 2 Programming By Example) by David Maxwell

Author:David Maxwell
Language: eng
Format: mobi, epub, azw3
Published: 2016-03-30T21:00:00+00:00


<ul>

<li ng-repeat="x in thefirstapp">{{x}}</li>

</ul>

</div>

<script>

var app = angular.module('TheFirstApp', []);

app.controller('myCtrl', function($scope) {

$scope.names = ["the", "first", "app"];

});

</script>

Root Scope

There’s also such a thing as Root Scope (also known as $rootscope). This uses the ng-app directive and is available for the whole application—so you can say that it’s a really important part of the tutorial. This also uses the scope that’s currently used.

For example:

<body ng-app="TheFirstApp">

<p>The rootScope's favorite color:</p>

<h1>{{pink}}</h1>

<div ng-controller="myCtrl">

<p>The scope of the controller's favorite color:</p>

<h1>{{purple}}</h1>

</div>

<p>The rootScope's favorite color is still:</p>

<h1>{{pink}}</h1>

<script>

var app = angular.module('TheFirstApp', []);

app.run(function($rootScope) {

$rootScope.color = 'pink';

});

app.controller('myCtrl', function($scope) {

$scope.color = "purple";

});

</script>

</body>



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.