Skip to content

Commit 132d8e9

Browse files
committed
fix(slides): set class using renderer instead of host
fixes #6275
1 parent f355087 commit 132d8e9

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

ionic/components/slides/slides.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Directive, Component, ElementRef, Host, EventEmitter, Input, Output, ChangeDetectionStrategy, ViewEncapsulation} from 'angular2/core';
1+
import {Directive, Component, ElementRef, Renderer, Host, EventEmitter, Input, Output, ChangeDetectionStrategy, ViewEncapsulation} from 'angular2/core';
22
import {NgClass} from 'angular2/common';
33

44
import {Ion} from '../ion';
@@ -193,9 +193,6 @@ import {Scroll} from '../scroll/scroll';
193193
'<div [class.hide]="!showPager" class="swiper-pagination"></div>' +
194194
'</div>',
195195
directives: [NgClass],
196-
host: {
197-
'[class]': 'slideId'
198-
},
199196
changeDetection: ChangeDetectionStrategy.OnPush,
200197
encapsulation: ViewEncapsulation.None,
201198
})
@@ -340,14 +337,16 @@ export class Slides extends Ion {
340337
@Output() move: EventEmitter<any> = new EventEmitter();
341338

342339

343-
constructor(elementRef: ElementRef) {
340+
constructor(elementRef: ElementRef, renderer: Renderer) {
344341
super(elementRef);
345342
this.rapidUpdate = debounce(() => {
346343
this.update();
347344
}, 10);
348345

349346
this.id = ++slidesId;
350347
this.slideId = 'slides-' + this.id;
348+
349+
renderer.setElementClass(elementRef.nativeElement, this.slideId, true);
351350
}
352351

353352
/**

ionic/components/slides/test/controller/main.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<ion-slides #mySlider [options]="mySlideOptions" (didChange)="onSlideChanged()">
1+
<ion-slides #mySlider [options]="mySlideOptions" (didChange)="onSlideChanged()" class="my-slides">
22
<ion-slide padding>
33
<h1>Slide 1</h1>
44
<button block (click)="goToPrevSlide()">Navigate Back</button>

0 commit comments

Comments
 (0)