I am trying to implement a Crop Plugin Library in my angular demo project. I have injected the required modules to my main module and successfully cropped a pic. But I don't know how to pass the base64 string to the controller. What I have tried so far is:
var myApp = angular.module('myModule', ['ngRoute', 'angular-img-cropper', 'app']);
myApp.config(function($routeProvider) {
$routeProvider
.when('/multiple',{
templateUrl: 'templates/multi.html',
controller: 'multiController',
controllerAs: 'multiCtrl'
})
});
myApp.controller('multiController', function ($scope,$rootScope) {
var vm = this;
vm.clickButton = function () {
console.log("photo: "+vm.member_photo);
};
});
HTML - templates/multi.html:
<h1>Multi page which has another controller inside</h1>
<div ng-controller="multiController">
<div ng-controller="ImageCropperCtrl as ctrl">
<input type="file" img-cropper-fileread image="cropper.sourceImage" />
<div>
<canvas width="500" height="300" id="canvas" image-cropper image="cropper.sourceImage" cropped-image="cropper.croppedImage" crop-width="500" crop-height="200" min-width="100" min-height="50" keep-aspect="true" crop-area-bounds="bounds"></canvas>
</div>
<div>Cropped Image (Left: {{bounds.left}} Right: {{bounds.right}} Top: {{bounds.top}} Bottom: {{bounds.bottom}})</div>
<div ng-show="cropper.croppedImage!=null"><img ng-model="member_photo1" ng-src="{{cropper.croppedImage}}" /></div>
<textarea name="member_photo" ng-model="multiCtrl.member_photo" id="member_photo" class="form-control valid">{{cropper.croppedImage}}</textarea>
</div>
<button ng-controller="insideController" ng-click="multiCtrl.clickButton()">Console.log</button>
</div>
If I inspect the textarea the value is there but it is not shown inside the textarea and also the value cannot be accessed inside my controller. What am I doing wrong?