I am using cropper.js to crop the images I wrote a directive which will take the image src
return {
restrict: 'A',
controller: _cropperController,
bindToController: {
imagesrc:"=?"
},
link:function($scope, $element, $attrs, ctrl){
var img = document.createElement("img");
img.src = ctrl.imagesrc;
img.id='image';
document.getElementsByTagName("body")[0].appendChild(img);
Cropper.setDefaults({
checkCrossOrigin: false
});
var cropper = new Cropper(img, {
aspectRatio: 1 / 1,
checkCrossOrigin: false,
crop: function(e) {
console.log(e.detail.x);
console.log(e.detail.y);
}
});
if(cropper.getCroppedCanvas()){
var imgurl = cropper.getCroppedCanvas().toDataURL();
ctrl.imagesrc= imgurl;
}
}
};
Then create the image element, append it to dom and them pass the image to the cropper constructor
I have set default options checkCrossOrigin to false but still giving the error
No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:9090' is therefore not allowed access.
Any help would be appreciated.
Take an example of chrome extensions. If we place our author URL in permissible URL's then Cross module calls will not be stopped.
Otherwise it will always go as OPTIONS instead of POST/GET.