Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitce2b853

Browse files
committed
refactor(carousel): carousel.config migrate to inject()
1 parentd16cae1 commitce2b853

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

‎projects/coreui-angular/src/lib/carousel/carousel.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ export class CarouselConfig {
99
/* Default direction of auto changing of slides */
1010
direction:'next'|'prev'='next';
1111
/* Default interval of auto changing of slides */
12-
interval=0;
12+
interval?:number;
1313
}

‎projects/coreui-angular/src/lib/carousel/carousel/carousel.component.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ describe('CarouselComponent', () => {
4141
expect(component.activeIndex()).toBe(0);
4242
expect(component.animate()).toBe(true);
4343
expect(component.direction()).toBe('next');
44-
expect(component.interval()).toBe(0);
44+
expect(component.interval()).toBe(-1);
4545
});
4646

4747
it('should call timer functions',fakeAsync(()=>{

‎projects/coreui-angular/src/lib/carousel/carousel/carousel.component.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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
})
3939
exportclassCarouselComponentimplementsOnInit,OnDestroy,AfterContentInit{
40+
privateconfig=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)privateconfig: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-
readonlyactiveIndexInput=input<number>(0,{alias:'activeIndex'});
63+
readonlyactiveIndexInput=input(0,{alias:'activeIndex',transform:numberAttribute});
6264

6365
readonlyactiveIndex=linkedSignal({
6466
source:this.activeIndexInput,
@@ -92,7 +94,7 @@ export class CarouselComponent implements OnInit, OnDestroy, AfterContentInit {
9294
*@return number
9395
*@default 0
9496
*/
95-
readonlyintervalInput=input<number>(0,{alias:'interval'});
97+
readonlyintervalInput=input(-1,{alias:'interval',transform:numberAttribute});
9698

9799
readonlyinterval=linkedSignal({
98100
source:this.intervalInput,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp