@@ -246,7 +246,6 @@ angular.module('ui.bootstrap.carousel', [])
246246 */
247247. directive ( 'uibCarousel' , [ function ( ) {
248248 return {
249- restrict : 'EA' ,
250249 transclude : true ,
251250 replace : true ,
252251 controller : 'UibCarouselController' ,
@@ -421,11 +420,24 @@ angular.module('ui.bootstrap.carousel')
421420
422421. value ( '$carouselSuppressWarning' , false )
423422
423+ . controller ( 'CarouselController' , [ '$scope' , '$element' , '$controller' , '$log' , '$carouselSuppressWarning' , function ( $scope , $element , $controller , $log , $carouselSuppressWarning ) {
424+ if ( ! $carouselSuppressWarning ) {
425+ $log . warn ( 'CarouselController is now deprecated. Use UibCarouselController instead.' ) ;
426+ }
427+
428+ return $controller ( 'UibCarouselController' , {
429+ $scope : $scope ,
430+ $element : $element
431+ } ) ;
432+ } ] )
433+
424434. directive ( 'carousel' , [ '$log' , '$carouselSuppressWarning' , function ( $log , $carouselSuppressWarning ) {
425435 return {
426- restrict : 'EA' ,
427436 transclude : true ,
428437 replace : true ,
438+ controller : 'CarouselController' ,
439+ controllerAs : 'carousel' ,
440+ require : 'carousel' ,
429441 templateUrl : function ( element , attrs ) {
430442 return attrs . templateUrl || 'template/carousel/carousel.html' ;
431443 } ,
@@ -445,8 +457,7 @@ angular.module('ui.bootstrap.carousel')
445457
446458. directive ( 'slide' , [ '$log' , '$carouselSuppressWarning' , function ( $log , $carouselSuppressWarning ) {
447459 return {
448-
449- restrict : 'EA' ,
460+ require : '^carousel' ,
450461 transclude : true ,
451462 replace : true ,
452463 templateUrl : function ( element , attrs ) {
@@ -461,6 +472,18 @@ angular.module('ui.bootstrap.carousel')
461472 if ( ! $carouselSuppressWarning ) {
462473 $log . warn ( 'slide is now deprecated. Use uib-slide instead.' ) ;
463474 }
475+
476+ carouselCtrl . addSlide ( scope , element ) ;
477+ //when the scope is destroyed then remove the slide from the current slides array
478+ scope . $on ( '$destroy' , function ( ) {
479+ carouselCtrl . removeSlide ( scope ) ;
480+ } ) ;
481+
482+ scope . $watch ( 'active' , function ( active ) {
483+ if ( active ) {
484+ carouselCtrl . select ( scope ) ;
485+ }
486+ } ) ;
464487 }
465488 } ;
466489} ] ) ;
0 commit comments