Created
November 25, 2014 08:59
-
-
Save whisher/cf4ac38951f32bdcc59b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html ng-app="myApp"> | |
<head> | |
<title>Directives</title> | |
</head> | |
<body> | |
<div ng-controller="ChildController as child"> | |
<button type="button" ng-click="child.sayMe()">Say me!</button> | |
</div> | |
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-rc.1/angular.min.js"></script> | |
<script> | |
var app = angular.module('myApp', []) | |
app.controller('BaseController',function() { | |
this.me = 'Base'; | |
this.sayMe= function() { | |
alert(this.me); | |
} | |
}); | |
app.controller('ChildController', function($scope, $controller) { | |
var controller = $controller('BaseController as base', {$scope: $scope}); | |
angular.extend(this, controller); | |
this.me = 'Child'; | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment