55 * Use of this source code is governed by an MIT-style license that can be
66 * found in the LICENSE file at https://angular.io/license
77 */
8- import {
9- Directive ,
10- DoCheck ,
11- ElementRef ,
12- Input ,
13- IterableDiffers ,
14- KeyValueDiffers ,
15- Optional ,
16- Renderer2 ,
17- Self ,
18- } from '@angular/core' ;
19- import { NgClass } from '@angular/common' ;
8+ import { Directive , DoCheck , ElementRef , Input , Optional , Self } from '@angular/core' ;
9+ import { NgClass , ɵNgClassImpl , ɵNgClassR2Impl } from '@angular/common' ;
2010import { BaseDirective2 , StyleUtils , MediaMarshaller } from '@angular/flex-layout/core' ;
2111
2212export class ClassDirective extends BaseDirective2 implements DoCheck {
@@ -36,17 +26,13 @@ export class ClassDirective extends BaseDirective2 implements DoCheck {
3626 constructor ( protected elementRef : ElementRef ,
3727 protected styler : StyleUtils ,
3828 protected marshal : MediaMarshaller ,
39- protected iterableDiffers : IterableDiffers ,
40- protected keyValueDiffers : KeyValueDiffers ,
41- protected renderer : Renderer2 ,
29+ protected delegate : ɵNgClassImpl ,
4230 @Optional ( ) @Self ( ) protected readonly ngClassInstance : NgClass ) {
4331 super ( elementRef , null ! , styler , marshal ) ;
4432 if ( ! this . ngClassInstance ) {
4533 // Create an instance NgClass Directive instance only if `ngClass=""` has NOT been defined on
4634 // the same host element; since the responsive variations may be defined...
47- this . ngClassInstance = new NgClass (
48- this . iterableDiffers , this . keyValueDiffers , this . elementRef , this . renderer
49- ) ;
35+ this . ngClassInstance = new NgClass ( this . delegate ) ;
5036 }
5137 this . init ( ) ;
5238 this . setValue ( '' , '' ) ;
@@ -81,12 +67,18 @@ const selector = `
8167 [ngClass.gt-xs], [ngClass.gt-sm], [ngClass.gt-md], [ngClass.gt-lg]
8268` ;
8369
70+ // tslint:disable-next-line:variable-name
71+ export const LayoutNgClassImplProvider = {
72+ provide : ɵNgClassImpl ,
73+ useClass : ɵNgClassR2Impl
74+ } ;
75+
8476/**
8577 * Directive to add responsive support for ngClass.
8678 * This maintains the core functionality of 'ngClass' and adds responsive API
8779 * Note: this class is a no-op when rendered on the server
8880 */
89- @Directive ( { selector, inputs} )
81+ @Directive ( { selector, inputs, providers : [ LayoutNgClassImplProvider ] } )
9082export class DefaultClassDirective extends ClassDirective {
9183 protected inputs = inputs ;
9284}
0 commit comments