This repository was archived by the owner on May 29, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -687,6 +687,9 @@ angular.module('ui.bootstrap.modal', ['ui.bootstrap.stackedMap'])
687
687
ctrlInstance . $close = modalScope . $close ;
688
688
ctrlInstance . $dismiss = modalScope . $dismiss ;
689
689
angular . extend ( ctrlInstance , providedScope ) ;
690
+ if ( angular . isFunction ( ctrlInstance . $onInit ) ) {
691
+ ctrlInstance . $onInit ( ) ;
692
+ }
690
693
}
691
694
692
695
modalScope [ modalOptions . controllerAs ] = ctrlInstance ;
Original file line number Diff line number Diff line change @@ -826,6 +826,27 @@ describe('$uibModal', function() {
826
826
} ) ;
827
827
expect ( $document ) . toHaveModalOpenWithContent ( 'Content from ctrl true bar' , 'div' ) ;
828
828
} ) ;
829
+
830
+ it ( 'should have $onInit called' , function ( ) {
831
+ var $scope = $rootScope . $new ( true ) ;
832
+ var $onInit = jasmine . createSpy ( '$onInit' ) ;
833
+ $scope . foo = 'bar' ;
834
+ open ( {
835
+ template : '<div>{{test.fromCtrl}} {{test.closeDismissPresent()}} {{test.foo}}</div>' ,
836
+ controller : function ( $uibModalInstance ) {
837
+ this . $onInit = $onInit ;
838
+ this . fromCtrl = 'Content from ctrl' ;
839
+ this . closeDismissPresent = function ( ) {
840
+ return angular . isFunction ( this . $close ) && angular . isFunction ( this . $dismiss ) ;
841
+ } ;
842
+ } ,
843
+ controllerAs : 'test' ,
844
+ bindToController : true ,
845
+ scope : $scope
846
+ } ) ;
847
+ expect ( $document ) . toHaveModalOpenWithContent ( 'Content from ctrl true bar' , 'div' ) ;
848
+ expect ( $onInit ) . toHaveBeenCalled ( ) ;
849
+ } ) ;
829
850
} ) ;
830
851
831
852
describe ( 'resolve' , function ( ) {
You can’t perform that action at this time.
0 commit comments