Why do I get undefined for application.android.context in nativescript-angular app?

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
Leave a Reply

avatar
1 Comment threads
0 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
1 Comment authors
Jason Recent comment authors
  Subscribe  
newest oldest most voted
Notify of
Jason
Guest

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