Skip to content

Commit 7bcebb5

Browse files
committed
Bug #103 error creating options if none provided
1 parent fb0ba0f commit 7bcebb5

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

examples/01-simple.html

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,15 +145,26 @@ <h1>AngularJS Color Picker</h1>
145145
</div>
146146

147147
<div class="row">
148-
<h2>No Options</h2>
148+
<h2>HTML Options</h2>
149149
<label class="control-label">Color</label>
150-
<color-picker class='col-sm-1' ng-model="entity.color" options="{'format':'hex','swatchOnly':true}" /></color-picker>
150+
<color-picker class='col-sm-1' ng-model="color2" options="{'format':'hex','swatchOnly':true}"></color-picker>
151151
</div>
152152

153153
<div class="row">
154154
Two Way Binding
155155
{{color2}}
156156
</div>
157+
158+
<div class="row">
159+
<h2>No Options</h2>
160+
<label class="control-label">Color</label>
161+
<color-picker class='col-sm-1' ng-model="color3"></color-picker>
162+
</div>
163+
164+
<div class="row">
165+
Two Way Binding
166+
{{color3}}
167+
</div>
157168
</form>
158169
</div>
159170
</body>

src/scripts/controller.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,10 @@ export default class AngularColorPickerController {
365365
}
366366

367367
initConfig () {
368+
if (!this.options) {
369+
this.options = {};
370+
}
371+
368372
this.mergeOptions(this.options, this.ColorPickerOptions);
369373

370374
this.visible = this.options.inline;
@@ -375,9 +379,7 @@ export default class AngularColorPickerController {
375379
}
376380

377381
mergeOptions(options, defaultOptions) {
378-
var attr;
379-
380-
for (attr in defaultOptions) {
382+
for (var attr in defaultOptions) {
381383
if (defaultOptions.hasOwnProperty(attr)) {
382384
if (!options || !options.hasOwnProperty(attr)) {
383385
options[attr] = defaultOptions[attr];

0 commit comments

Comments
 (0)