@@ -4,10 +4,10 @@ import {
44 DestroyRef ,
55 effect ,
66 ElementRef ,
7- Inject ,
87 inject ,
98 input ,
109 linkedSignal ,
10+ numberAttribute ,
1111 OnDestroy ,
1212 OnInit ,
1313 output
@@ -37,28 +37,30 @@ import { CarouselConfig } from '../carousel.config';
3737 }
3838} )
3939export class CarouselComponent implements OnInit , OnDestroy , AfterContentInit {
40+ private config = inject < CarouselConfig > ( CarouselConfig ) ;
41+
4042 readonly #hostElement = inject ( ElementRef ) ;
4143 readonly #carouselService = inject ( CarouselService ) ;
4244 readonly #carouselState = inject ( CarouselState ) ;
4345 readonly #intersectionService = inject ( IntersectionService ) ;
4446 readonly #listenersService = inject ( ListenersService ) ;
4547
46- constructor ( @ Inject ( CarouselConfig ) private config : CarouselConfig ) {
48+ constructor ( ) {
4749 this . loadConfig ( ) ;
4850 }
4951
5052 loadConfig ( ) {
51- this . activeIndex . set ( this . config ?. activeIndex ?? this . activeIndex ( ) ) ;
52- this . animate . set ( this . config ?. animate ?? this . animate ( ) ) ;
53- this . direction . set ( this . config ?. direction ?? this . direction ( ) ) ;
54- this . interval . set ( this . config ?. interval ?? this . interval ( ) ) ;
53+ this . activeIndex . update ( ( activeIndex ) => this . config ?. activeIndex ?? activeIndex ) ;
54+ this . animate . update ( ( animate ) => this . config ?. animate ?? animate ) ;
55+ this . direction . update ( ( direction ) => this . config ?. direction ?? direction ) ;
56+ this . interval . update ( ( interval ) => this . config ?. interval ?? interval ) ;
5557 }
5658
5759 /**
5860 * Index of the active item.
5961 * @return number
6062 */
61- readonly activeIndexInput = input < number > ( 0 , { alias : 'activeIndex' } ) ;
63+ readonly activeIndexInput = input ( 0 , { alias : 'activeIndex' , transform : numberAttribute } ) ;
6264
6365 readonly activeIndex = linkedSignal ( {
6466 source : this . activeIndexInput ,
@@ -92,7 +94,7 @@ export class CarouselComponent implements OnInit, OnDestroy, AfterContentInit {
9294 * @return number
9395 * @default 0
9496 */
95- readonly intervalInput = input < number > ( 0 , { alias : 'interval' } ) ;
97+ readonly intervalInput = input ( - 1 , { alias : 'interval' , transform : numberAttribute } ) ;
9698
9799 readonly interval = linkedSignal ( {
98100 source : this . intervalInput ,
0 commit comments