1.1.1 • Published 7 years ago

ng2-color-picker-4th v1.1.1

Weekly downloads
77
License
MIT
Repository
github
Last release
7 years ago

ng2-color-picker-4th

Simple color picker for Angular 2 with ng-bootstrap dependency

Screenshot open

Dependencies

The module relies on ng-bootstrap for dropdown functionality. (https://ng-bootstrap.github.io)

Installation

To include in your project install via NPM with:

npm install --save ng2-color-picker-4th

You will then need to include the module to your app.module.ts:

import { ColorPickerModule } from 'ng2-color-picker-4th';

// ...

@NgModule({
    imports: [
        ColorPickerModule
    ]
})
///...

Finally, include the component in your HTML as per the next section.

HTML Component Markup

Once the module is installed, you will need to add HTML markup to include the picker in a component. The minimum requirement is an (ngModel) attribute, which should provide a string representation of a color.

<color-picker
    [(ngModel)]="color">
</color-picker>

It is possible to configure ng2-color-picker by providing a configuration object to the [pickerConfig] attribute (see the next section for more details on this object):

<color-picker
    [(ngModel)]="color"
    [pickerConfig]="pickerOptions">
</color-picker>

Configuration

ng2-color-picker exposes an interface to provide an indication of valid configuration properties, this can be referenced as a type for your configuration object by importing it:

import { IPickerConfiguration } from 'ng2-color-picker-4th';

Which can then be used as the configuration object type in your component:

public pickerOptions: IPickerConfiguration;

Current list of configuration options, types and default values:

PropertyTypeDefaultDescription.
widthnumber25Width of the picker control.
heightnumber25Height of the picker control.
borderRadiusnumber4Radius of the picker control border.
availableColorsstring[]['#f00', '#0f0', '#00f']Default list of colors available from the dropdown menu.