Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ngImgCrop doesn't work properly with ng-flow #182

Open
luizadavtyan opened this issue Sep 6, 2017 · 0 comments
Open

ngImgCrop doesn't work properly with ng-flow #182

luizadavtyan opened this issue Sep 6, 2017 · 0 comments

Comments

@luizadavtyan
Copy link

I am using ng-flow package to upload images. After user uploads image, i open bootstrap modal in which user does the cropping.
Here is sample of my code.
the image upload part:

<div class="profice-pic-wrap">
	<div class="thumbnail round" ng-hide="$flow.files.length">
	    <img flow-btn src="img/placeholder-person.jpg" style="cursor: pointer;" class="round thum" />
	</div>
	<div class="thumbnail" ng-show="$flow.files.length">
	   <img class="thum round" flow-btn flow-img="$flow.files[0]" ng-src="{{outputImageNew}}" style="cursor:pointer;"/>
	</div>
</div>

the cropping modal:

<div id="cropModal" class="modal fade" role="dialog">
	<div class="modal-dialog">
	   <div class="modal-content">
		      <div class="modal-header">
		      </div>
		      <div class="modal-body">
		        <div class="cropArea">
			        <img-crop image="imageString" result-image="$root.outputImage" area-type="square"></img-crop>
			</div>
		     </div>
		      <div class="modal-footer">
		        <button type="button" class="btn btn-default" translate="ok" translate-default="&nbsp;" ng-click="hideModal()"></button>
		     </div>
	   </div>
	</div>
</div>

code from my controller:

$scope.processFiles = function(files){
	$('#cropModal').modal({
	 backdrop: 'static',
		 keyboard: false
	})
	$('#cropModal').modal('show');
	$('#cropModal').on('shown.bs.modal', function() {
	$scope.imageStrings = [];
	$rootScope.outputImage = null;
	$scope.imageString = null;
	$scope.inputImage = null;
	var fileReader = new FileReader();
	fileReader.onload = function (event) {
	$scope.$apply(function($scope){
	    	      var uri = event.target.result;
		              $scope.imageString = uri;
	    	        });
	    	      };		          
	 fileReader.readAsDataURL(files[0].file);
	    })
	};

$scope.hideModal = function() {
	$('#cropModal').modal('hide');
	$scope.outputImageNew = $rootScope.outputImage;
}

When i upload an image, modal opens and i do the cropping. After that i close the modal and the cropped image appears in the img with ng-src="{{outputImageNew}}". But if i do this process several times, when modal opens i can see the previous uploaded image in my modal for a moment(or images, changing very quickly, if i repeat the process several times). Sometimes the image doesn't even appear in modal, it only shows the last uploaded one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant