Is there a way to get reference to the currently instantiated controller object from within the controller's definition? I'd like to $compile
a modal and bind that to the same controller that's creating the modal.
Here's a simplified version of what I'd like to do, where THIS_CONTROLLER_INSTANCE
is a reference to my controller instance.
angular.module('foo')
.controller('barController', function($scope, $rootScope){
$scope.openModal = function(){
var modalEl = $('<div class="modal">Modal stuff here</div>');
var controller = THIS_CONTROLLER_INSTANCE;
modalEl.contents().data('$ngControllerController', THIS_CONTROLLER_INSTANCE);
$compile(modalEl)($scope);
$('body').append(modalEl);
}
});