Permalink
Browse files

fix(carousel): use only public methods in template

A private method `_getSlideEventDirection` was used in the carousel template,
and that was throwing an error with the Angular compiler option `fullTemplateTypeCheck`.
This makes the method public to fix the issue.

Related to #2038

Closes #2040
  • Loading branch information...
cexbrayat authored and pkozlowski-opensource committed Dec 14, 2017
1 parent f1137aa commit da31c3ed2aca9a217e877c92cc1a779a16028db3
Showing with 10 additions and 10 deletions.
  1. +10 −10 src/carousel/carousel.ts
View
@@ -46,8 +46,8 @@ export class NgbSlide {
},
template: `
<ol class="carousel-indicators">
<li *ngFor="let slide of slides" [id]="slide.id" [class.active]="slide.id === activeId"
(click)="cycleToSelected(slide.id, _getSlideEventDirection(activeId, slide.id))"></li>
<li *ngFor="let slide of slides" [id]="slide.id" [class.active]="slide.id === activeId"
(click)="cycleToSelected(slide.id, getSlideEventDirection(activeId, slide.id))"></li>
</ol>
<div class="carousel-inner">
<div *ngFor="let slide of slides" class="carousel-item" [class.active]="slide.id === activeId">
@@ -120,7 +120,7 @@ export class NgbCarousel implements AfterContentChecked,
* Navigate to a slide with the specified identifier.
*/
select(slideId: string) {
this.cycleToSelected(slideId, this._getSlideEventDirection(this.activeId, slideId));
this.cycleToSelected(slideId, this.getSlideEventDirection(this.activeId, slideId));
this._restartTimer();
}
@@ -164,6 +164,13 @@ export class NgbCarousel implements AfterContentChecked,
}
}
getSlideEventDirection(currentActiveSlideId: string, nextActiveSlideId: string): NgbSlideEventDirection {
const currentActiveSlideIdx = this._getSlideIdxById(currentActiveSlideId);
const nextActiveSlideIdx = this._getSlideIdxById(nextActiveSlideId);
return currentActiveSlideIdx > nextActiveSlideIdx ? NgbSlideEventDirection.RIGHT : NgbSlideEventDirection.LEFT;
}
keyPrev() {
if (this.keyboard) {
this.prev();
@@ -215,13 +222,6 @@ export class NgbCarousel implements AfterContentChecked,
return isFirstSlide ? (this.wrap ? slideArr[slideArr.length - 1].id : slideArr[0].id) :
slideArr[currentSlideIdx - 1].id;
}
private _getSlideEventDirection(currentActiveSlideId: string, nextActiveSlideId: string): NgbSlideEventDirection {
const currentActiveSlideIdx = this._getSlideIdxById(currentActiveSlideId);
const nextActiveSlideIdx = this._getSlideIdxById(nextActiveSlideId);
return currentActiveSlideIdx > nextActiveSlideIdx ? NgbSlideEventDirection.RIGHT : NgbSlideEventDirection.LEFT;
}
}
/**

0 comments on commit da31c3e

Please sign in to comment.