diff --git a/src/modal/modal.js b/src/modal/modal.js index 3025e0d136..f591088161 100644 --- a/src/modal/modal.js +++ b/src/modal/modal.js @@ -687,6 +687,9 @@ angular.module('ui.bootstrap.modal', ['ui.bootstrap.stackedMap']) ctrlInstance.$close = modalScope.$close; ctrlInstance.$dismiss = modalScope.$dismiss; angular.extend(ctrlInstance, providedScope); + if (angular.isFunction(ctrlInstance.$onInit)) { + ctrlInstance.$onInit(); + } } modalScope[modalOptions.controllerAs] = ctrlInstance; diff --git a/src/modal/test/modal.spec.js b/src/modal/test/modal.spec.js index fae3a34556..84d22f50ba 100644 --- a/src/modal/test/modal.spec.js +++ b/src/modal/test/modal.spec.js @@ -826,6 +826,27 @@ describe('$uibModal', function() { }); expect($document).toHaveModalOpenWithContent('Content from ctrl true bar', 'div'); }); + + it('should have $onInit called', function() { + var $scope = $rootScope.$new(true); + var $onInit = jasmine.createSpy('$onInit'); + $scope.foo = 'bar'; + open({ + template: '