【问题标题】:Why do I get undefined for application.android.context in nativescript-angular app?为什么我在 nativescript-angular 应用程序中未定义 application.android.context?
【发布时间】:2016-04-14 13:19:28
【问题描述】:

尝试在 nativescript-angular 应用程序中使用 nativescript-clipboard 插件时出现以下错误。 因为我是 nativescript 的新手,所以我很可能做错了什么。

这是完整的错误:

clipboard.setText 中的错误:TypeError:无法读取属性 未定义的“getSystemService” (/home/linuxtest/sample-ng-todomvc/node_modules/nativescript-clipboard/clipboard.android.js:13:15) 我是

目前有 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);
        });
    }
}

提前致谢!

【问题讨论】:

    标签: android angular clipboard nativescript


    【解决方案1】:

    我已将解决方案记录在您在作者存储库中打开的问题中,但为了让社区获得答案,我也会在此处发布链接。 Solution to this problem in the authors repository

    【讨论】:

    • 好的,非常感谢!我设法更进一步,并将对您的库的引用定义为类属性,而不是两次。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-12
    • 1970-01-01
    相关资源
    最近更新 更多