javascript - Angular: reference currently instantiated controller -


is there way reference instantiated controller object within controller's definition? i'd $compile modal , bind same controller that's creating modal.

here's simplified version of i'd do, this_controller_instance reference 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);   } }); 

as noted above:

the current controller this. solution problem is:

angular.module('foo') .controller('barcontroller', function($scope, $rootscope){   var self = this;   $scope.openmodal = function(){     var modalel = $('<div class="modal">modal stuff here</div>');     var controller = self;     modalel.contents().data('$ngcontrollercontroller', controller);      $compile(modalel)($scope);     $('body').append(modalel);   } }); 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -