File tree 2 files changed +15
-1
lines changed
2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change 25
25
$scope . $watch ( 'input' , function ( v ) {
26
26
$scope . copied = false
27
27
} ) ;
28
+
29
+ $scope . clipError = function ( e ) {
30
+ console . log ( 'Error: ' + e . name + ' - ' + e . message ) ;
31
+ } ;
28
32
} ] ) ;
29
33
</ script >
30
34
</ head >
@@ -36,7 +40,7 @@ <h1>Angular ZeroClipboard Demo</h1>
36
40
< div >
37
41
< h1 > Copy from input</ h1 >
38
42
< label for =""> input: < input type ="text " ng-model ="input " id ="input1 "> </ label >
39
- < button ui-zeroclip zeroclip-copied ="complete($event) " zeroclip-model ="input " > Copy</ button >
43
+ < button ui-zeroclip zeroclip-copied ="complete($event) " zeroclip-on-error =" clipError($event) " zeroclip- model ="input " > Copy</ button >
40
44
< span ng-show ="copied "> Copied!</ span >
41
45
</ div >
42
46
Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ angular.module('zeroclipboard', [])
34
34
return {
35
35
scope : {
36
36
onCopied : '&zeroclipCopied' ,
37
+ onError : '&?zeroclipOnError' ,
37
38
client : '=?uiZeroclip' ,
38
39
value : '=zeroclipModel' ,
39
40
text : '@zeroclipText'
@@ -64,6 +65,15 @@ angular.module('zeroclipboard', [])
64
65
} ) ;
65
66
} ) ;
66
67
68
+ client . on ( 'error' , function ( e ) {
69
+ if ( scope . onError ) {
70
+ scope . $apply ( function ( ) {
71
+ scope . onError ( { $event : e } ) ;
72
+ } ) ;
73
+ }
74
+ ZeroClipboard . destroy ( ) ;
75
+ } ) ;
76
+
67
77
scope . $on ( '$destroy' , function ( ) {
68
78
client . off ( 'complete' , _completeHnd ) ;
69
79
} ) ;
You can’t perform that action at this time.
0 commit comments