2016-04-14 53 views
0

在嘗試在nativescript-angular應用中使用nativescript-clipboard插件時,出現以下錯誤。 因爲我是新手,我很可能做錯了什麼。爲什麼我在nativescript-angular應用程序中獲取undefined for application.android.context?

這是完全錯誤:

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

目前有插件的版本1.1.3。

而這裏就是我想用你的插件

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); 
     }); 
    } 
} 

提前感謝節!

回答

1

我已經在作者資源庫中打開的問題中記錄瞭解決方案,但爲了社區獲得答案,還將在此處發佈鏈接。 Solution to this problem in the authors repository

+1

恩,非常感謝!我設法進一步將它定義爲類屬性,而不是兩次。 –

相關問題