Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | 1x 1x 1x 1x 164x 164x 20675x 5167x 205x 7x 33x | import { Injectable } from '@angular/core'; import { NavigationStart, Router } from '@angular/router'; import { Observable, Subject } from 'rxjs'; import { CarouselModel } from '../models'; /** * Carousel Service */ @Injectable() export class CarouselService { /** collection of carousel */ private readonly subject = new Subject<CarouselModel>(); /** * constructor of CarouselService * @param router: Router */ constructor(router: Router) { // clear carousel on route change router.events.subscribe(event => { if (event instanceof NavigationStart) { this.subject.next(); } }); } /** * init carousel * @param carouselModel: CarouselModel */ init(carouselModel: CarouselModel): void { if (carouselModel) { this.subject.next(carouselModel); } } /** * get current carousel */ getCarousel(): Observable<CarouselModel> { return this.subject.asObservable(); } } |