1

I'm getting the following error while trying to use the nativescript-clipboard plugin within a nativescript-angular app. Because I'm new to nativescript I'm most likely doing something wrong.

This is the complete error:

Error in clipboard.setText: TypeError: Cannot read property 'getSystemService' of undefined (/home/linuxtest/sample-ng-todomvc/node_modules/nativescript-clipboard/clipboard.android.js:13:15) I'm

currently have version 1.1.3 of the plugin.

And here is the section where I'm trying to use your plugin

import {Component} from "angular2/core";
var clipboardModule = require("nativescript-clipboard");


@Component({
    selector: "my-clipboard",
    templateUrl: "templates/my-clipboard.html"
})
export class MyClipboard {
    greeting:string;
    constructor(){
        this.greeting = "Hello Github!";
    }

    save(text) {
        clipboardModule.setText(text).then(()=>{
            console.log(texto + ", copied to clipboard");
        });
    }

    read() {
        clipboardModule.getText().then((content)=>{
            console.log("Read from clipboard: " + content);
        });
    }
}

Thanks in advance!

1 Answer 1

2

I have logged the solution in the issue you have opened in the authors repository but in order for the community to get the answer will post a link here as well. Solution to this problem in the authors repository

Sign up to request clarification or add additional context in comments.

1 Comment

Well, thank you very much! I managed to take it a little further and define the reference to your library as a class attribute instead of doing it twice.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.