Skip to content

Commit

Permalink
Understanding root scope
Browse files Browse the repository at this point in the history
  • Loading branch information
praneethkumarpidugu committed Jun 23, 2016
1 parent 50f0196 commit 855b0f8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
12 changes: 11 additions & 1 deletion section4/lesson2/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,16 @@


<div class="container" >

<div class="row" >
<div class="col-md-6" >
<div class="root">
<label >
<input type="text"
ng-model="name" />
</label >
<p >{{name}}</p >
<div class="row" >
<div class="" >
<div class="parent"
ng-controller="ParentController" >
<label >
Expand All @@ -40,6 +47,9 @@
</div >
</div >
</div >
</div>
</div>
</div>


<script src="../libs/angular/angular.min.js" ></script >
Expand Down
17 changes: 10 additions & 7 deletions section4/lesson2/main.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
var app = angular.module('codecraft', []);

app.controller('ParentController', function ($scope) {
$scope.name = "Parent";

$scope.reset = function () {
$scope.name = "Parent";
};
app.controller('ParentController', function ($scope, $rootScope) {
// $scope.name = "Parent";
//
// $scope.reset = function () {
// $scope.name = "Parent";
// };

});

app.controller('ChildController', function ($scope) {
app.controller('ChildController', function ($scope, $rootScope) {
$scope.reset = function() {
$rootScope.name = "Reset By Child";
};
});


0 comments on commit 855b0f8

Please sign in to comment.