From 9c20f10a1d2566958841364602e2bf03d34fb823 Mon Sep 17 00:00:00 2001 From: Adam Bradley Date: Wed, 24 May 2017 14:44:26 -0500 Subject: [PATCH] feat(item): listen for core $ionStyle events --- src/components/item/item.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/components/item/item.ts b/src/components/item/item.ts index 0700a284f3..c17914e0bd 100644 --- a/src/components/item/item.ts +++ b/src/components/item/item.ts @@ -1,4 +1,4 @@ -import { ChangeDetectionStrategy, Component, ContentChild, ElementRef, QueryList, Renderer, Optional, ViewChild, ViewEncapsulation } from '@angular/core'; +import { ChangeDetectionStrategy, Component, ContentChild, ElementRef, HostListener, QueryList, Renderer, Optional, ViewChild, ViewEncapsulation } from '@angular/core'; import { Config } from '../../config/config'; import { Form } from '../../util/form'; @@ -334,6 +334,15 @@ export class Item extends Ion { } } + @HostListener('$ionStyle', ['$event']) + itemStyle(ev: any) { + ev.stopPropagation(); + + Object.keys(ev.detail).forEach(cssClassName => { + this._elementRef.nativeElement.classList[ev.detail[cssClassName] ? 'add' : 'remove']('item-' + cssClassName); + }); + } + /** * @hidden */