File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change 2525 $scope . $watch ( 'input' , function ( v ) {
2626 $scope . copied = false
2727 } ) ;
28+
29+ $scope . clipError = function ( e ) {
30+ console . log ( 'Error: ' + e . name + ' - ' + e . message ) ;
31+ } ;
2832 } ] ) ;
2933 </ script >
3034</ head >
@@ -36,7 +40,7 @@ <h1>Angular ZeroClipboard Demo</h1>
3640 < div >
3741 < h1 > Copy from input</ h1 >
3842 < 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 >
4044 < span ng-show ="copied "> Copied!</ span >
4145 </ div >
4246
Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ angular.module('zeroclipboard', [])
3434 return {
3535 scope : {
3636 onCopied : '&zeroclipCopied' ,
37+ onError : '&?zeroclipOnError' ,
3738 client : '=?uiZeroclip' ,
3839 value : '=zeroclipModel' ,
3940 text : '@zeroclipText'
@@ -64,6 +65,15 @@ angular.module('zeroclipboard', [])
6465 } ) ;
6566 } ) ;
6667
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+
6777 scope . $on ( '$destroy' , function ( ) {
6878 client . off ( 'complete' , _completeHnd ) ;
6979 } ) ;
You can’t perform that action at this time.
0 commit comments