|
1 |
| -import { OnInit, OnChanges, Directive, Input, Output, EventEmitter, ElementRef, ViewContainerRef, ReflectiveInjector, ComponentFactoryResolver } from '@angular/core'; |
| 1 | +import { OnInit, OnChanges, Directive, Input, Output, EventEmitter, ElementRef, ViewContainerRef, ReflectiveInjector, ComponentFactoryResolver, ChangeDetectorRef } from '@angular/core'; |
2 | 2 |
|
3 | 3 | import { ColorPickerService } from './color-picker.service';
|
4 | 4 | import { ColorPickerComponent } from './color-picker.component';
|
@@ -44,7 +44,7 @@ export class ColorPickerDirective implements OnInit, OnChanges {
|
44 | 44 | private created: boolean;
|
45 | 45 | private ignoreChanges: boolean = false;
|
46 | 46 |
|
47 |
| - constructor(private vcRef: ViewContainerRef, private el: ElementRef, private service: ColorPickerService, private cfr: ComponentFactoryResolver) { |
| 47 | + constructor(private vcRef: ViewContainerRef, private el: ElementRef, private service: ColorPickerService, private cfr: ComponentFactoryResolver, private cdr: ChangeDetectorRef) { |
48 | 48 | this.created = false;
|
49 | 49 | }
|
50 | 50 |
|
@@ -76,7 +76,11 @@ export class ColorPickerDirective implements OnInit, OnChanges {
|
76 | 76 | if (hsva == null) {
|
77 | 77 | hsva = this.service.stringToHsva(this.cpFallbackColor);
|
78 | 78 | }
|
79 |
| - this.colorPickerChange.emit(this.service.outputFormat(hsva, this.cpOutputFormat, this.cpAlphaChannel === 'hex8')); |
| 79 | + let color = this.service.outputFormat(hsva, this.cpOutputFormat, this.cpAlphaChannel === 'hex8'); |
| 80 | + if (color !== this.colorPicker) { |
| 81 | + this.colorPickerChange.emit(color); |
| 82 | + this.cdr.detectChanges(); |
| 83 | + } |
80 | 84 | }
|
81 | 85 |
|
82 | 86 | onClick() {
|
|
0 commit comments