Git Product home page Git Product logo

ng-clip's Introduction

ngClip - Copy to clipboard using AngularJS

An AngularJS simple directive that uses ZeroClipboard and updates the user's clipboard.

Usage

  1. Add ng-clip.js to your main file (index.html)

  2. Use bower to obtain the latest version ZeroClipboard from the official repository. if you are missing bower, use npm(Node Packaged Modules) to obtain it with the following command:

npm install -g bower

bower install zeroclipboard
2a. If you use [yeoman](http://yeoman.io/), the js file will be automatically included within your project dependencies.

You may want to update the ngClip.js file, and replace the cdnjs resource with you own local copy: 

```javascript
 value('ZeroClipboardPath', '//cdnjs.cloudflare.com/ajax/libs/zeroclipboard/1.2.3/ZeroClipboard.swf').

```
Just change this path the correct location of the swf file of the plugin in your file system, relatively to your project's root(this step is optional):

```javascript
 value('ZeroClipboardPath', 'relative-path/to/ZeroClipboard.swf').
```

It is thus recommended to use [yeoman](http://yeoman.io/), since it will save you a great deal of time, and will improve your code structure.

2b. If you don't use yeoman, you'll have to follow the instructions in 2a. and additionally, add the javascript ZeroClipboard file to the buttom of your index\main application page,
somewhere after angular.js and before the ngClip.js file should be fine(not critical):
```html
<script type="text/javascript" src="relative-path/to/ZeroClipBoard.js"></script>
```
Alternatively, if you wish to use this library from CDN, it is available on cdnjs:
```html
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/zeroclipboard/1.2.3/ZeroClipboard.swf"></script>
```
  1. Set ngClipboard as a dependency in your module
var myapp = angular.module('myapp', ['ngClipboard'])
  1. Add clip-copy directive to the wanted element, example:
<a href="" clip-copy="getTextToCopy()" clip-click="doSomething()">Copy</a>

Example

You can check out this live example here: http://jsfiddle.net/asafdav/8YQcz/6/

Bitdeli Badge

ng-clip's People

Contributors

asafdav avatar bitdeli-chef avatar lorenzo-stoakes avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.