Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Override default selected color after initialization #275

Open
Yorer opened this issue Mar 12, 2020 · 7 comments
Open

Override default selected color after initialization #275

Yorer opened this issue Mar 12, 2020 · 7 comments

Comments

@Yorer
Copy link

Yorer commented Mar 12, 2020

This is not a bug, this is 2 requests:

  1. Once you've created color component (e.g.: color-sketch), I am unable to override programmatically it's value, because seems like "[color]" input parameter seems like one way binded, it doesn't care the color object has changed on parent even if I try to send like this: "[(color)]".

  2. Is it possible to modify preset colors somehow? If not please can you put that in?

Thanks

@scttcper
Copy link
Owner

Make sure you’re triggering change detection and replacing the color object you are passing and not modifying it

@davidecampello
Copy link

Hi, I'm having the same problem. Where should I trigger the change detection?

@scttcper
Copy link
Owner

check out how the demo works, its doing exactly this. https://github.com/scttcper/ngx-color/blob/master/src/app/app.component.ts

@davidecampello
Copy link

I did not understood the first message, sorry. I'll open a new issue with the problem I have

@everettglovier
Copy link

I'd like to add the same issue. I cannot change the color of the component after initialization. I have attempted to change the color, currentColor, and hex variables. Nothing seems to work. This is a problem if you are trying to programmatically make changes using this.component.color for example.

@everettglovier
Copy link

A workaround for anyone looking is to manually force ngOnChanges after a change in your component:

this.yourColorComponent.color = '#000000';
this.yourColorComponent.ngOnChanges();

@EvyRondon
Copy link

I followed this: https://github.com/scttcper/ngx-color/blob/master/src/app/app.component.ts

Then I put state on my load method:

async loadData(id: string) {
const { success, data } = await this.vehicleTypeSrv.GetById(id);
if (success) {
this.form = data;
this.state = data.color;
}
}

That's worked for me!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants