ngCropper icon indicating copy to clipboard operation
ngCropper copied to clipboard

ngCropper doesn't work in Angular Modal

Open iceNuts opened this issue 8 years ago • 3 comments

Hi there,

I use code from demo in angular modal view, however, the crop view doesn't show up when I upload a file. Is there any solution for this?

Thanks.

iceNuts avatar Dec 28 '15 21:12 iceNuts

For more information, I use demo code and it has error like (In 'element.cropper(options)', 'element.cropper' is undefined) It looks like the cropper is not initialized properly.

iceNuts avatar Dec 29 '15 09:12 iceNuts

Hi, I had this issue before. What I want to do is to zoom in & zoom out with slider bar. So, I put my code in ngCropper directive. For example,

link: function(scope, element, atts) {
      var shown = false;

      scope.$on(scope.showEvent, function() {
        if (shown) return;
        shown = true;

        preprocess(scope.options, element[0])
          .then(function(options) {
            setProxy(element);

            /**
             *  Zoom in & Zoom out slidebar
            **/
            scope.$watch('zoomvalue', function(delta){
              element.cropper('zoom',  delta * 0.1);
            });
            element.cropper(options);
          })
      });

So it seems that this part

/**
*  Zoom in & Zoom out slidebar
**/
scope.$watch('zoomvalue', function(delta){
   element.cropper('zoom',  delta * 0.1);
});

has to be placed before " element.cropper(options); "

Five-stars-Coffee avatar Jan 20 '16 02:01 Five-stars-Coffee

Hi iceNuts, You can workaround the problem, if you change element.cropper(options) to $(element).cropper(options) in the source. I actually had this issue and this fixed.

pankyka avatar Mar 22 '16 10:03 pankyka