标签: nativescript

Nativescript:如何以编程方式禁用/启用ScrollView滚动?

有没有办法在NativeScript中以编程方式禁用/启用ScrollView滚动?

android ios nativescript

2
推荐指数
1
解决办法
3704
查看次数

如何在Nativescript中向ActionBar添加按钮图标?

嗨有人!

我正在尝试在我的Nativescript应用程序中为ActionBar添加一个汉堡菜单图标,这将触发一个侧抽屉,但我无法添加该菜单图标.

这是关于此事官方文件 ;

.xml到目前为止这是我的代码:

<dpg:DrawerPage loaded="pageLoaded" navigatedTo="onNavigatingTo"  
xmlns:dpg="nativescript-telerik-ui/sidedrawer/drawerpage"
xmlns:drawer="nativescript-telerik-ui/sidedrawer"
xmlns:sdc="views/side-drawer-content"
xmlns="http://www.nativescript.org/tns.xsd">
<navigation.actionBar>
  <ActionBar title="Drawer Over Navigation">
    <android>
      <NavigationButton icon="res://ic_menu" tap="toggleDrawer" />
    </android>
    <ios>
      <ActionItem icon="res://ic_menu" ios.position="left" tap="toggleDrawer" />
    </ios>
  </ActionBar>
</navigation.actionBar>

<dpg:DrawerPage.sideDrawer>
<drawer:RadSideDrawer id="drawer">
  <drawer:RadSideDrawer.drawerContent>
    <sdc:side-drawer-content />
  </drawer:RadSideDrawer.drawerContent>
</drawer:RadSideDrawer> 
</dpg:DrawerPage.sideDrawer>

<StackLayout cssClass="mainContent">
    <Label text="{{ exampleText }}" textWrap="true" cssClass="drawerContentText"/>
    <Button text="Toggle Drawer" tap="toggleDrawer" icon="res://ic_menu" />
</StackLayout>
</dpg:DrawerPage>
Run Code Online (Sandbox Code Playgroud)

我认为相关部分在这里,但我看不出可能是我的错误.

<ActionBar title="Drawer Over Navigation">
    <android>
      <NavigationButton icon="res://ic_menu" tap="toggleDrawer" />
    </android>
    <ioThanks in advance!s>
      <ActionItem icon="res://ic_menu" ios.position="left" tap="toggleDrawer" /> …
Run Code Online (Sandbox Code Playgroud)

xml android telerik nativescript

2
推荐指数
1
解决办法
5583
查看次数

是否可以让孩子加入自定义组件?

是否可以让孩子加入自定义组件?

<myCustomComponent>
    <Label #id1 text="ID 1"></Label>
    <Label #id2 text="ID 2"></Label>
</myCustomComponent>
Run Code Online (Sandbox Code Playgroud)

有没有办法获取这两个的引用,Lable以将它们放置GridLayout在我的自定义组件中?

nativescript

2
推荐指数
1
解决办法
1551
查看次数

NativeScript ng2双向绑定在TextField上不起作用

即时通讯制作移动应用.在我的登录表单中,我有2个TextFields

<TextField hint="Email Address" keyboardType="email" [(ngModel)]="email" autocorrect="false" autocapitalizationType="none"></TextField>
<TextField hint="Password" secure="true" [(ngModel)]="password"></TextField>
 <Label [text]="email"></Label>
Run Code Online (Sandbox Code Playgroud)

在component.ts中

import { Component, OnInit } from '@angular/core';
import { Router } from "@angular/router";
import { NativeScriptRouterModule } from "nativescript-angular/router";
import { Page } from "ui/page";
import * as Toast from 'nativescript-toast';
@Component({
    moduleId: module.id,
    selector: 'sign-in',
    templateUrl: "template.html"
})
export class SignInPage implements OnInit {
    email: string ="example";
    password: string;
    constructor(private router: Router, page: Page) {
        page.actionBarHidden = true;
    }
    ngOnInit() {

        var loginParams = …
Run Code Online (Sandbox Code Playgroud)

typescript nativescript angular2-forms angular2-nativescript angular

2
推荐指数
1
解决办法
1532
查看次数

找不到名称“标头”,“ RequestInit”,“响应”

我将本机脚本从2.5.2更新到了3.0.3。突然,当我尝试运行该应用程序时,出现以下错误:

node_modules / tns-core-modules / tns-core-modules.d.ts(17,27):错误TS2304:找不到名称“ Headers”。

node_modules / tns-core-modules / tns-core-modules.d.ts(19,44):错误TS2304:找不到名称“ RequestInit”。

node_modules / tns-core-modules / tns-core-modules.d.ts(19,66):错误TS2304:找不到名称“ Response”。

我不明白为什么,因为我认为我没有在项目中使用此模块。

谢谢!:)

module header response nativescript angular2-nativescript

2
推荐指数
1
解决办法
1215
查看次数

使用angular和rxjs实现轮询

我想用角度应用程序在我的nativescript中实现轮询.我想每秒检查一下后端服务器的状态.我有这项服务:

@Injectable()
export class StateService {
getStatus(): Observable<StateApp> {
        let headers = this.getHeaders();
        return this.http
            .get(BackendService.stateUrl, {
                headers: headers
            })
            .map(res => {
                return res.json() as StateApp
            })
            .catch(this.handleErrors);
}
Run Code Online (Sandbox Code Playgroud)

然后我想挂起这个服务并向服务器发送请求.在我组件的组件中,我有以下代码:

IntervalObservable.create(1000).subscribe(() => {
            this.statusService.getStatus()
                .subscribe(
                (next) => {
                    this.state = next;
                };
        });
Run Code Online (Sandbox Code Playgroud)

我试图实现我在这里阅读的解决方案,它处理相同的问题(但它是差不多2年前的帖子)Angular2 http在一个时间间隔,但是例如当我写IntervalObservable.takeWhile时它不再存在(rxjs)版本5.4.3).所以我想知道实现相同结果的方式是什么(即第一次不等待一秒钟获取结果并在组件被销毁时停止发送请求)

rxjs typescript nativescript angular

2
推荐指数
1
解决办法
2718
查看次数

使用HttpClient时带有Angular错误的Nativescript

我试图HttpClient在我的Nativescript应用程序中使用Angular ,但是当我在我的组件中导入它时,我得到了Error: Trying to link invalid 'this' to a Java object

更新

我也尝试在Groceries示例中添加它而不更改任何其他内容,但它不起作用

{
      "description": "ArkCash",
      "license": "SEE LICENSE IN <your-license-filename>",
      "readme": "NativeScript Application",
      "repository": "<fill-your-repository-here>",
      "nativescript": {
        "id": "arkcash.chbtechnologies.ch.arkcash_mobile",
        "tns-android": {
          "version": "3.2.0"
        }
      },
      "dependencies": {
        "@angular/animations": "~4.4.6",
        "@angular/common": "~4.4.6",
        "@angular/compiler": "~4.4.6",
        "@angular/core": "~4.4.6",
        "@angular/forms": "~4.4.6",
        "@angular/http": "~4.4.6",
        "@angular/platform-browser": "~4.4.6",
        "@angular/platform-browser-dynamic": "~4.4.6",
        "@angular/router": "~4.4.6",
        "@ngrx/core": "^1.2.0",
        "@ngrx/effects": "^2.0.5",
        "@ngrx/router-store": "^4.1.0",
        "@ngrx/store": "^2.2.3",
        "angular2-jwt": "^0.2.3",
        "lodash": "^4.17.4",
        "moment": "^2.19.1",
        "nativescript-angular": "~4.4.1",
        "nativescript-drop-down": "^3.2.0",
        "nativescript-fabric": "^1.0.6",
        "nativescript-pro-ui": …
Run Code Online (Sandbox Code Playgroud)

nativescript angular2-nativescript angular

2
推荐指数
1
解决办法
1709
查看次数

如何在订阅中返回Observable

我想在可观察对象内部调用http请求,这使得从数据库进行选择操作。我做了两个服务,DbServiceBackendService

BackendService发出http发布请求并返回响应数据。在我的设计中,BackendService应该订阅DbService来获取URL,之后发出http发布请求,然后返回响应数据。

BackendService可以从DbService获取url,并尝试发出http请求,但不能。响应数据为(Json格式)

{"_isScalar":false,"source":{"_isScalar":false},"operator":{}}
Run Code Online (Sandbox Code Playgroud)

我不明白这里发生了什么。我的服务和AppComponent文件在下面。

有BackendService

import { Injectable } from "@angular/core";
import { getString, setString } from "application-settings";
import { Headers, Http, Response, RequestOptions } from "@angular/http";
import { Observable } from "rxjs/Observable";
import 'rxjs/add/observable/of';
import "rxjs/add/operator/do";
import "rxjs/add/operator/map";
import "rxjs/add/observable/throw";
import "rxjs/add/operator/catch";
import { DbService } from "./db.service";

@Injectable()
export class BackendService {
    static BaseUrl= "http://blabla.com"

    constructor(public http: Http, private db: DbService) {
    }

        sendPost(key: string, requestObj: Object):Observable<any>{
        console.log("sendPost: ");
        return new Observable(obs=> { …
Run Code Online (Sandbox Code Playgroud)

typescript nativescript angular2-observables angular

2
推荐指数
1
解决办法
1万
查看次数

NativeScript:GridLayout对齐问题

我是新来的NativeScript。我正在遵循自己的文件。我正在尝试UI对齐。我无法实现这一目标。我正在使用Xcode IDE并在中运行iOS Simulator

杂货徽标应位于顶部

文字栏位应在中间

注册按钮应该在底部

尝试1

<Page loaded="loaded">

<GridLayout height=auto horizontalAlignment="center" verticalAlignment="center" columns="*" rows="auto,auto,*"  backgroundColor="brown">
    <Image src="res://logo" stretch="aspectFit" horizontalAlignment="center" verticalAlignment="top" col="0" row="0"></Image>
    <GridLayout columns="*" rows="auto,auto,auto" verticalAlignment="center" backgroundColor="lightgray" col="0" row="1">

        <TextField class="userTxtFld" id="email" text="{{ email }}" hint="Email Address" keyboardType="email" autocorrect="false" autocapitalizationType="none"  col="0" row="0"/>
        <TextField secure="true" text="{{ password }}" hint="Password" col="0" row="1"/>
        <Button text="Sign in" tap="signIn"  col="0" row="2"/>

    </GridLayout>
    <Button text="Sign up for Groceries" class="link" tap="register" verticalAlignment="bottom" col="0" row="2"/>
</GridLayout>
</Page>
Run Code Online (Sandbox Code Playgroud)

尝试2

<Page loaded="loaded">

<GridLayout …
Run Code Online (Sandbox Code Playgroud)

xml grid-layout nativescript nativescript-telerik-ui

2
推荐指数
1
解决办法
1686
查看次数

NativeScript Sidekick-UnhandledPromiseRejectionWarning:未定义原始语言

启动NativeScript Sidekick时,我从Windows出现了一个异常,指出以下内容(此错误消息也显示在Sidekick的输出Errors中):(UnhandledPromiseRejectionWarning: ReferenceError: primordials is not defined为了更容易阅读,可以在底部找到错误的完整堆栈跟踪)

除了安装NativeScript Sidekick并打开应用程序外,我什么都没做。

我该如何解决这个问题?

(CLI) (node:6632) UnhandledPromiseRejectionWarning: ReferenceError: primordials is not defined
    at fs.js:27:35
    at req_ (userFolder\AppData\Roaming\.nativescript-cli\extensions\node_modules\natives\index.js:143:24)
    at Object.req [as require] (userFolder\AppData\Roaming\.nativescript-cli\extensions\node_modules\natives\index.js:55:10)
    at Object.<anonymous> (userFolder\AppData\Roaming\.nativescript-cli\extensions\node_modules\fstream\node_modules\graceful-fs\fs.js:1:37)
    at Module._compile (internal/modules/cjs/loader.js:759:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:770:10)
    at Module.load (internal/modules/cjs/loader.js:628:32)
    at Function.Module._load (internal/modules/cjs/loader.js:555:12)
    at Module.require (internal/modules/cjs/loader.js:666:19)
    at require (internal/modules/cjs/helpers.js:16:16)
    at Object.<anonymous> (userFolder\AppData\Roaming\.nativescript-cli\extensions\node_modules\fstream\node_modules\graceful-fs\graceful-fs.js:3:27)
    at Module._compile (internal/modules/cjs/loader.js:759:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:770:10)
    at Module.load (internal/modules/cjs/loader.js:628:32)
    at Function.Module._load (internal/modules/cjs/loader.js:555:12)
    at Module.require (internal/modules/cjs/loader.js:666:19)
    at emitWarning (internal/process/promises.js:120:15)
    at processPromiseRejections (internal/process/promises.js:168:7)
    at processTicksAndRejections (internal/process/task_queues.js:90:32)
(node:6632) ReferenceError: …
Run Code Online (Sandbox Code Playgroud)

windows node.js gulp nativescript sidekick

2
推荐指数
1
解决办法
873
查看次数