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

Error, when no value in colorPicker variable #7

Closed
jhiemer opened this issue May 9, 2016 · 2 comments
Closed

Error, when no value in colorPicker variable #7

jhiemer opened this issue May 9, 2016 · 2 comments

Comments

@jhiemer
Copy link

jhiemer commented May 9, 2016

Hi,
I had to add

    ngOnInit() {
      if (this.colorPicker) {
        let hsva = this.service.stringToHsva(this.colorPicker);
        if (hsva !== null) {
            this.colorPickerChange.emit(this.service.outputFormat(hsva, this.cpOutputFormat));
        }
      }
    }

to the directive, to get it going. Is this correct?

@Alberplz
Copy link
Owner

Alberplz commented May 9, 2016

Hi,
The idea is provide a value, if you don't, you can use a empty string:
color: string= ''
and the default color will be #f00.

If the color is undefined would be something like this:
ngOnInit() {
if (!this.colorPicker) this.colorPicker = '';
let hsva = this.service.stringToHsva(this.colorPicker);
if (hsva !== null) {
this.colorPickerChange.emit(this.service.outputFormat(hsva, this.cpOutputFormat));
}
}

Well...in some cases the directive could be inside of a form and the value not defined yet.
I'm adding in the next update undefined variables and a new option for the default value when is not defined (now is #f00 when is a empty string).

@Alberplz
Copy link
Owner

Alberplz commented Jun 4, 2016

New parameter added cpFallbackColor

@Alberplz Alberplz closed this as completed Jun 4, 2016
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

2 participants