colorpicker icon indicating copy to clipboard operation
colorpicker copied to clipboard

Problem showing color list

Open fati13592 opened this issue 8 years ago • 8 comments

Hi, i've just try your color picker and this is what is happening. sin titulo

It only shows the little rectangle on the left. I copy paste the example. If anyone have any idea, i would be very happy :D

fati13592 avatar Mar 07 '16 12:03 fati13592

I have the same problem, nothing appears :p

IssamEssarghini033 avatar May 23 '16 11:05 IssamEssarghini033

I ran into the same issue. The below re-structuring of the directive caused it to work for me in Angular v 1.4.7. Note the removal of the vm from vm.property in the $templateCache.put call.

angular.module('tb-color-picker', [])
    .run(['$templateCache', function ($templateCache) {
        $templateCache.put('color-picker.tp1.html', '<div class="color-picker">' +
            '<div class="selected-color" ng-style="{\'background-color\': color}"></div>' +
            '<div class="color-palette">' +
                '<div ng-repeat="option in options"' +
                'ng-style="{\'background-color\': option}"' +
                'ng-class="{\'palette-selected-color\': option == color, \'transparent-color\': option == \'tranparent\'}"' +
                'ng-click="changeColor(option)"></div>' +
            '</div>' +
        '</div>');
    }])
    .directive('colorPicker', function () {
        return {
            restrict: 'E',
            templateUrl: 'color-picker.tp1.html',
            replace: true,
            scope: {
                color: '=',
                options: '=',
                onColorChanged: '&',
            },
            link: function (scope) {
                scope.changeColor = function (option) {
                    var old = scope.color;
                    scope.color = option;
                    scope.onColorChanged({ newColor: option, oldColor: old });
                }
            }
        };
    });

JaimeStill avatar Jun 13 '16 20:06 JaimeStill

JaimeStill your code is fine!

saulo3k avatar Apr 06 '17 19:04 saulo3k

@saulo3k, I'm glad it helped!

JaimeStill avatar Apr 06 '17 23:04 JaimeStill

@JaimeStill thanks for the input :) Is this caused by Angular's version? If your code works on latest version of angular I'll update the master!

bladepop avatar Apr 08 '17 20:04 bladepop

@bladepop Congratulations for your module, my angular version is 1.4.8

saulo3k avatar Apr 08 '17 23:04 saulo3k

@bladepop, it's been quite a while since I messed with it, but I was using angular version 1.4.7 when I made the above adjustment. If I recall correctly, the changes were made to simplify the composition of the directive. Because the controller created in your code was specific to the directive, I just isolated the properties to the directive scope and defined the logic in the link function.

JaimeStill avatar Apr 11 '17 13:04 JaimeStill

@JaimeStill your code is fine! Thanks

diegosoek avatar Apr 17 '19 23:04 diegosoek