<div class="container" data-ng-app=""> <div ng-controller="parentCtrl"> <h1>부모 이름 : {{parent.name}}</h1> <div ng-controller="childCtrl" style="padding-left: 20px;"> <h2>부모이름 : {{parent.name}}</h2> <h2>자식이름 : {{child.name}}</h2> <button type="button" class="btn btn-default" ng-click="changeParentName()">부모이름변경</button> </div> </div> </div>
var parentCtrl = function($scope){ $scope.parent = {name: "parent Kim"}; }; var childCtrl = function($scope){ $scope.child = {name: "child Ko"}; $scope.changeParentName = function(){ $scope.parent.name = "another Kim"; }; };