-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathtest.html
47 lines (38 loc) · 1.35 KB
/
test.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<!DOCTYPE html>
<html lang="en" ng-app="cropper-test">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body ng-controller="MainController as main">
<div>
<input type="file" accept="image/*" simple-change="file = $event.target.files[0]">
</div>
<canvas width="400" height="400" tw-cropper="cropper" source="file"></canvas>
<button ng-click="crop = cropper.toDataURL()">Crop</button>
<img ng-src="{{crop}}">
<script src="node_modules/angular/angular.js"></script>
<script src="node_modules/angular-file-reader/angular-file-reader.js"></script>
<script src="angular-cropper.js"></script>
<script>
angular.module('cropper-test', ['tw.directives.cropper']);
angular.module('cropper-test').controller('MainController', function() {
});
angular.module('cropper-test').directive('simpleChange', function simpleChangeDirective() {
return {
restrict: 'A',
link: function(scope, el, attrs) {
if (!attrs.simpleChange) return;
el.on('change', function(e) {
scope.$apply(function() {
scope.$eval(attrs.simpleChange, {
$event: e
});
});
});
}
};
});
</script>
</body>
</html>