Open melalitesh opened 5 years ago
Show me your code
getColorFromRGB(){
let hex = this.rgbToHex(this.coolColor.rgb.red, this.coolColor.rgb.green, this.coolColor.rgb.blue);
this.coolColor.hexString = '#'+hex;
this.coolColor.rgb.red = Number(this.coolColor.rgb.red)
this.coolColor.rgb.green = Number(this.coolColor.rgb.green)
this.coolColor.rgb.blue = Number(this.coolColor.rgb.blue)
let hsl = this.rgbToHsl(this.coolColor.rgb.red, this.coolColor.rgb.green, this.coolColor.rgb.blue);
this.coolColor.hsl.hue = hsl[0];
this.coolColor.hsl.saturation = hsl[1];
this.coolColor.hsl.lightness = hsl[2];
}
<ng-color-box (ngModelChange)="colorChange($event)" [(ngModel)]="coolColor" startHex="coolColor.hexString"></ng-color-box>
Try setting everything in one go, like this:
getColorFromRGB(){
let hex = this.rgbToHex(this.coolColor.rgb.red, this.coolColor.rgb.green, this.coolColor.rgb.blue);
this.coolColor = {
hexString: ...,
rgb: {
red: ...
}
}
this look a little bit wrong to me:
this.coolColor.rgb.red = Number(this.coolColor.rgb.red)
It is using itself to set itself? Inception
Hi,
I want to set the color of picker from .ts file, but changing the hexstring doesn't change the picker color.
Please suggest