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 33
33
< h1 > Angular ZeroClipboard Demo</ h1 >
34
34
35
35
< 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 >
39
42
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 >
41
49
</ form >
42
50
43
51
</ body >
Original file line number Diff line number Diff line change @@ -35,7 +35,8 @@ angular.module('zeroclipboard', [])
35
35
scope : {
36
36
onCopied : '&zeroclipCopied' ,
37
37
client : '=?uiZeroclip' ,
38
- value : '=zeroclipModel'
38
+ value : '=zeroclipModel' ,
39
+ text : '@zeroclipText'
39
40
} ,
40
41
link : function ( scope , element , attrs ) {
41
42
// config
@@ -47,6 +48,11 @@ angular.module('zeroclipboard', [])
47
48
}
48
49
49
50
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 ) {
50
56
element . attr ( 'data-clipboard-text' , v ) ;
51
57
} ) ;
52
58
You can’t perform that action at this time.
0 commit comments