javascript - How to copy text inside an HTML element into clipboard using ng-clip? -


i'm creating simple angularjs app using ng-clip. code:

<!doctype html> <html> <head>   <link href="https://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet">   <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.15/angular.min.js"></script>   <script src="src/zeroclipboard.min.js"></script>   <script src="src/ngclip.js"></script> </head> <body>  <div ng-app="myapp">   <div class="container" ng-controller="myctrl">      <div class="page-header">       <h3>simple script</h3>     </div>      <form>       <div class="form-group">         <label>name</label>         <input type="text" class="form-control" placeholder="" ng-model="name">       </div>       <div class="form-group">         <label>gender</label>         <input type="radio" ng-model="gender" value="male"> male <input type="radio" ng-model="gender" value="female"> female       </div>       <div class="form-group">         <label>dob</label>         <input type="text" class="form-control" placeholder="" ng-model="dob">       </div>       <p><strong>preview</strong></p>       <p ng-model="final">name: {{name}}<br/>         gender: {{gender}}<br/>         dob: {{dob}}</p>       <button class="btn btn-default" clip-copy="final">copy!</button>        <br><br>        <textarea class="form-control" rows="3" placeholder="test here"></textarea>     </form>   </div> </div>  <script>   var myapp = angular.module('myapp', ["ngclipboard"]);    myapp.config(['ngclipprovider', function(ngclipprovider) {     ngclipprovider.setpath("src/zeroclipboard.swf");   }]);    myapp.controller('myctrl', function ($scope) {     $scope.fallback = function(copy) {       window.prompt('press cmd+c copy text below.', copy);     };      $scope.showmessage = function() {       console.log("clip-click works!");     };   }); </script>  </body  > </html> 

plunker preview

plunker code

when click on "copy!" button, couldn't copy text inside final p element.

how copy entire text inside final p element clipboard?

it definately not work per doc ng-model cannot applied paragraph("<p>") tag.

the ngmodel directive binds input,select, textarea (or custom form control) property on scope using ngmodelcontroller, created , exposed directive.


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -