From 1b6cbbc0a94c045338c5f81d7c437a4445230c68 Mon Sep 17 00:00:00 2001 From: billyaraujo Date: Tue, 2 Jun 2015 18:37:34 +0100 Subject: [PATCH] Update angular-pick-a-color.js --- src/angular-pick-a-color.js | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/angular-pick-a-color.js b/src/angular-pick-a-color.js index 9a4c38c..78cd186 100644 --- a/src/angular-pick-a-color.js +++ b/src/angular-pick-a-color.js @@ -41,34 +41,40 @@ angular.module('pickAColor', []) return function (scope, element, attrs, controller) { // Process options var options = pickAColor.getOptions(); - if (attrs.inlineDropdown != null) { + if (attrs.inlineDropdown !== null) { options.inlineDropdown = attrs.inlineDropdown; } - if (attrs.showSpectrum != null) { + if (attrs.showSpectrum !== null) { options.showSpectrum = attrs.showSpectrum; } - if (attrs.showSavedColors != null) { + if (attrs.showSavedColors !== null) { options.showSavedColors = attrs.showSavedColors; } - if (attrs.saveColorsPerElement != null) { + if (attrs.saveColorsPerElement !== null) { options.saveColorsPerElement = attrs.saveColorsPerElement; } - if (attrs.fadeMenuToggle != null) { + if (attrs.fadeMenuToggle !== null) { options.fadeMenuToggle = attrs.fadeMenuToggle; } - if (attrs.showAdvanced != null) { + if (attrs.showAdvanced !== null) { options.showAdvanced = attrs.showAdvanced; } - if (attrs.showBasicColors != null) { + if (attrs.showBasicColors !== null) { options.showBasicColors = attrs.showBasicColors; } - if (attrs.showHexInput != null) { + if (attrs.showHexInput !== null) { options.showHexInput = attrs.showHexInput; } - if (attrs.allowBlank != null) { + if (attrs.allowBlank !== null) { options.allowBlank = attrs.allowBlank; } + scope.$watch(model, function(value) { + element.val(model(scope)); + element.focus(); + element.blur(); + }); + // Set the value before we initialise the picker element.val(model(scope));