@@ -253,7 +253,6 @@ angular.module('ui.bootstrap.carousel', [])
253
253
*/
254
254
. directive ( 'uibCarousel' , [ function ( ) {
255
255
return {
256
- restrict : 'EA' ,
257
256
transclude : true ,
258
257
replace : true ,
259
258
controller : 'UibCarouselController' ,
@@ -428,11 +427,24 @@ angular.module('ui.bootstrap.carousel')
428
427
429
428
. value ( '$carouselSuppressWarning' , false )
430
429
430
+ . controller ( 'CarouselController' , [ '$scope' , '$element' , '$controller' , '$log' , '$carouselSuppressWarning' , function ( $scope , $element , $controller , $log , $carouselSuppressWarning ) {
431
+ if ( ! $carouselSuppressWarning ) {
432
+ $log . warn ( 'CarouselController is now deprecated. Use UibCarouselController instead.' ) ;
433
+ }
434
+
435
+ return $controller ( 'UibCarouselController' , {
436
+ $scope : $scope ,
437
+ $element : $element
438
+ } ) ;
439
+ } ] )
440
+
431
441
. directive ( 'carousel' , [ '$log' , '$carouselSuppressWarning' , function ( $log , $carouselSuppressWarning ) {
432
442
return {
433
- restrict : 'EA' ,
434
443
transclude : true ,
435
444
replace : true ,
445
+ controller : 'CarouselController' ,
446
+ controllerAs : 'carousel' ,
447
+ require : 'carousel' ,
436
448
templateUrl : function ( element , attrs ) {
437
449
return attrs . templateUrl || 'template/carousel/carousel.html' ;
438
450
} ,
@@ -452,8 +464,7 @@ angular.module('ui.bootstrap.carousel')
452
464
453
465
. directive ( 'slide' , [ '$log' , '$carouselSuppressWarning' , function ( $log , $carouselSuppressWarning ) {
454
466
return {
455
-
456
- restrict : 'EA' ,
467
+ require : '^carousel' ,
457
468
transclude : true ,
458
469
replace : true ,
459
470
templateUrl : function ( element , attrs ) {
@@ -468,6 +479,18 @@ angular.module('ui.bootstrap.carousel')
468
479
if ( ! $carouselSuppressWarning ) {
469
480
$log . warn ( 'slide is now deprecated. Use uib-slide instead.' ) ;
470
481
}
482
+
483
+ carouselCtrl . addSlide ( scope , element ) ;
484
+ //when the scope is destroyed then remove the slide from the current slides array
485
+ scope . $on ( '$destroy' , function ( ) {
486
+ carouselCtrl . removeSlide ( scope ) ;
487
+ } ) ;
488
+
489
+ scope . $watch ( 'active' , function ( active ) {
490
+ if ( active ) {
491
+ carouselCtrl . select ( scope ) ;
492
+ }
493
+ } ) ;
471
494
}
472
495
} ;
473
496
} ] ) ;
0 commit comments