Angular: parent & child scope

http://angularjs.org/

by mrajcok

HTML

<div ng-controller="ParentCtrl">
  {{name}} here.
  <br><a ng-click="addStuff()">add new property</a>
    <p><p>
  <div ng-controller="ChildCtrl">
    {{name}} here.
    <br>event associations: {{associations.events}}
    </div>
</div>

JavaScript

function ParentCtrl($scope) {
    $scope.name = 'ParentCtrl';
    $scope.addStuff = function() {
        $scope. associations = {
         events: [ 'picnic', 'skiing' ],
         people: [],
         places: []
     };
    }
}

function ChildCtrl($scope) {
    $scope.name = 'ChildCtrl';  // shadows $parent.name
}