Need help upgrading to Ionic Framework 4.0? Get assistance with our Enterprise Migration Services EXPLORE NOW

Clipboard

Improve this doc

Clipboard management plugin for Cordova that supports iOS, Android, and Windows Phone 8.

Repo: https://github.com/ihadeed/cordova-clipboard

Installation

  1. Install the Cordova and Ionic Native plugins:
    $ ionic cordova plugin add cordova-clipboard
    $ npm install --save @ionic-native/clipboard@4
    
  2. Add this plugin to your app's module

Supported platforms

Usage

import { Clipboard } from '@ionic-native/clipboard';

constructor(private clipboard: Clipboard) { }

...


this.clipboard.copy('Hello world');

this.clipboard.paste().then(
   (resolve: string) => {
      alert(resolve);
    },
    (reject: string) => {
      alert('Error: ' + reject);
    }
  );

this.clipboard.clear();

Instance Members

copy(text)

Copies the given text

Param Type Details
text string

Text that gets copied on the system clipboard

Returns: Promise<any> Returns a promise after the text has been copied

paste()

Pastes the text stored in clipboard

Returns: Promise<any> Returns a promise after the text has been pasted

clear()

Clear the text stored in clipboard

Returns: Promise<any> Returns a promise after the text has been cleaned

API

Native

General