File tree Expand file tree Collapse file tree 2 files changed +19
-5
lines changed
Expand file tree Collapse file tree 2 files changed +19
-5
lines changed Original file line number Diff line number Diff line change 3333< h1 > Angular ZeroClipboard Demo</ h1 >
3434
3535< form action ="">
36- < label for =""> input: < input type ="text " ng-model ="input " id ="input1 "> </ label >
37- < button ui-zeroclip zeroclip-copied ="complete($event) " zeroclip-model ="input " > Copy</ button >
38- < span ng-show ="copied "> Copied!</ span >
36+ < div >
37+ < h1 > Copy from input</ h1 >
38+ < 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 >
40+ < span ng-show ="copied "> Copied!</ span >
41+ </ div >
3942
40- < label for =""> textarea: < textarea cols ="30 " rows ="10 " ui-zeroclip zeroclip-value- "textarea" ng-model="textarea "> </ textarea > </ label >
43+ < div >
44+ < h1 > Copy interpolated text</ h1 >
45+ < span > This will copy: "This input text: {{ input }}"</ span >
46+ < button ui-zeroclip zeroclip-copied ="copiedText=true " zeroclip-text ="This input text: {{ input }} " > Copy</ button >
47+ < span ng-show ="copiedText "> Copied!</ span >
48+ </ div >
4149</ form >
4250
4351</ body >
Original file line number Diff line number Diff line change @@ -35,7 +35,8 @@ angular.module('zeroclipboard', [])
3535 scope : {
3636 onCopied : '&zeroclipCopied' ,
3737 client : '=?uiZeroclip' ,
38- value : '=zeroclipModel'
38+ value : '=zeroclipModel' ,
39+ text : '@zeroclipText'
3940 } ,
4041 link : function ( scope , element , attrs ) {
4142 // config
@@ -47,6 +48,11 @@ angular.module('zeroclipboard', [])
4748 }
4849
4950 scope . $watch ( 'value' , function ( v ) {
51+ if ( v == undefined ) { return ; }
52+ element . attr ( 'data-clipboard-text' , v ) ;
53+ } ) ;
54+
55+ scope . $watch ( 'text' , function ( v ) {
5056 element . attr ( 'data-clipboard-text' , v ) ;
5157 } ) ;
5258
You can’t perform that action at this time.
0 commit comments