@@ -61,7 +61,7 @@ function mdCompilerService($q, $templateRequest, $injector, $compile, $controlle
6161 * - `link` - `{function(scope)}`: A link function, which, when called, will compile
6262 * the element and instantiate the provided controller (if given).
6363 * - `locals` - `{object}`: The locals which will be passed into the controller once `link` is
64- * called. If `bindToController` is true, they will be coppied to the ctrl instead
64+ * called. If `bindToController` is true, they will be copied to the ctrl instead
6565 * - `bindToController` - `bool`: bind the locals to the controller, instead of passing them in.
6666 */
6767 this . compile = function ( options ) {
@@ -112,12 +112,19 @@ function mdCompilerService($q, $templateRequest, $injector, $compile, $controlle
112112 link : function link ( scope ) {
113113 locals . $scope = scope ;
114114
115- //Instantiate controller if it exists, because we have scope
115+ // Instantiate controller if it exists, because we have scope
116116 if ( controller ) {
117- var invokeCtrl = $controller ( controller , locals , true , controllerAs ) ;
117+
118+ var ctrlLocals = angular . extend ( locals , {
119+ $element : element
120+ } ) ;
121+
122+ var invokeCtrl = $controller ( controller , ctrlLocals , true , controllerAs ) ;
123+
118124 if ( bindToController ) {
119125 angular . extend ( invokeCtrl . instance , locals ) ;
120126 }
127+
121128 var ctrl = invokeCtrl ( ) ;
122129 //See angular-route source for this logic
123130 element . data ( '$ngControllerController' , ctrl ) ;
0 commit comments