简体   繁体   English

为什么我在nativescript-angular app中为application.android.context获取未定义?

[英]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. 尝试在nativescript-angular应用程序中使用nativescript-clipboard插件时出现以下错误。 Because I'm new to nativescript I'm most likely doing something wrong. 因为我是Nativescript的新手,所以我很可能做错了什么。

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 Clipboard.setText中的错误:TypeError:无法读取未定义的属性“ getSystemService”(/ home / linuxtest / sample-ng-todomvc / node_modules / nativescript-clipboard / clipboard.android.js:13:15)

currently have version 1.1.3 of the plugin. 当前具有该插件的1.1.3版本。

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! 提前致谢!

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 在作者存储库中解决此问题的方法

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 有没有办法为nativescript-angular应用添加轮播? - is there a way to add carousel for nativescript-angular app? 在nativescript-angular应用中创建Spinner下拉列表 - Create Spinner dropdown list in nativescript-angular app 如何在 nativescript-angular 中为图像做 http post - How to do http post for image in nativescript-angular 如何在 Nativescript 中正确获取 Android 应用程序上下文 - How to properly get Android Application Context in Nativescript 如何使地理定位后台服务在我的nativescript-angular应用程序中工作? - How to make geolocation background services work in my nativescript-angular app? 找不到模块:“ nativescript-angular / http”,相对于:app / tns_modules / - Failed to find module: “nativescript-angular/http”, relative to: app/tns_modules/ 为什么在应用程序的构造函数中调用 android.content.Context.getApplicationContext() 时会得到 NPE? - Why do I get NPE when I invoke android.content.Context.getApplicationContext() within Application's constructor? Android:如何从扩展应用程序的 class 将应用程序上下文作为活动获取? - Android: How do I get the Application Context as an Activity from a class that extends Application? Android上带有Angular 2的Nativescript,如何关闭我的应用程序? - Nativescript with Angular 2 on Android, how to close my app? 我在下面的给定代码中将应用程序上下文作为什么放置(Android应用程序) - What do I put as the the application context in the given code below (Android app)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM