ruhley / angular-color-picker

Vanilla AngularJS Color Picker Directive with no requirement on jQuery
http://ruhley.github.io/angular-color-picker/
MIT License
166 stars 79 forks source link

Enhancement - add input name and id options #107

Closed ashconnell closed 8 years ago

ashconnell commented 8 years ago

A simple change to add id and name options to set attributes on the internal input.

The id attribute is useful if you use a label:

<label for="input-id">Choose a color</label>
<color-picker ng-model="color" options="{ id: 'input-id' }" />

The name attribute is useful for form validation and ng-messages:

<form name="myForm">
    <color-picker ng-model="color" options="{ name: 'color', required: true }" />
    <ng-messages for="myForm.color.$error" role="alert">
        <ng-message when="required">This field is required</ng-message>
    </ng-messages>
</form>
ruhley commented 8 years ago

Hi @ashconnell ,

Thanks for the PR, just a couple of things before I merge it in. Can you add these additional options to the options-service.js file, and make them default to undefined. I believe angularjs wlll not add the attribute if the value is undefined.

ashconnell commented 8 years ago

@ruhley done 39b789f :)

ruhley commented 8 years ago

I have released v2.4.5 with this update. Thanks for the PR :+1: . I don't know how this library has been around for so long without id or name....

ashconnell commented 8 years ago

@ruhley i'm not sure but thanks for creating this lib! It's clearly the best angular color picker around!