标签: nativescript-angular

我实现了在初始阶段就可以运行的iOS委托方法

本机脚本版本5.1.1

Xcode 10及更高版本,Mojave OS

SearchBar加载的功能

//Delegate Method Call
let delegate = MallSearchDelegate.initWithOriginalDelegate((<any>this.searchbar)._delegate);
(<any>this.searchbar)._delegate = delegate;
Run Code Online (Sandbox Code Playgroud)

代表班

export class MallSearchDelegate extends NSObject{
public static ObjCProtocols = [UISearchBarDelegate];
private _originalDelegate:UISearchBarDelegate;

public static initWithOriginalDelegate(originalDelegate: UISearchBarDelegate):MallSearchDelegate{
    let delegate = <MallSearchDelegate>MallSearchDelegate.new();
    delegate._originalDelegate = originalDelegate;
    console.log("Initialized SearchBar");
    return delegate;
}

public searchBarTextDidEndEditing(searchBar: UISearchBar):void{ 
    console.log("endSearch");
    if(((<any>this._originalDelegate)._owner)!=undefined){
        const owner = (<WeakRef<SearchBar>>(<any>this._originalDelegate)._owner).get();
        if (owner) {
            owner.notify({
                object: owner,
                eventName: "endSearch",
                focusable:false
            });
        }
    } 
}

public searchBarTextDidBeginEditing(searchBar: UISearchBar):void{ 
    console.log("beginSearch");
    if(((<any>this._originalDelegate)._owner)!=undefined){
        const owner = (<WeakRef<SearchBar>>(<any>this._originalDelegate)._owner).get();
        if (owner) {
            owner.notify({
                object: …
Run Code Online (Sandbox Code Playgroud)

runtime ios typescript nativescript-angular

5
推荐指数
0
解决办法
114
查看次数

在使用Angular的NativeScript中,如何获取id的接口元素?

我试图避免NativeScript应用程序中的意外行为.

当我走进任何具有搜索字段(SearchBar)的屏幕时,系统会自动将焦点放在搜索字段上.

然后我得到了一位朋友的帮助,他给了我一个解决这个问题的功能.但我现在面临的问题是我无法获得界面元素.我有以下代码:

import {Component} from "@angular/core";
import {Page} from "ui/page";
import frame = require("ui/frame");

@Component({
    selector: "clientes",
    templateUrl: "pages/clientes/clientes.html",
    styleUrls: ["pages/clientes/clientes.common.css",
    "pages/clientes/clientes.css"]
})

export class ClientesPage {

    page;

    constructor(private _router: Router) {
        this.page = <Page>frame.topmost().currentPage;
        this.removeSearchFocus();
    }

    removeSearchFocus() {
        var parent = this.page.getViewById('box-lista');
        var searchBar = this.page.getViewById('barra-busca');

        console.log(JSON.stringify(parent)); // UNDEFINED
        console.log(JSON.stringify(searchBar)); // UNDEFINED

        if (parent.android) {
            parent.android.setFocusableInTouchMode(true);
            parent.android.setFocusable(true);
            searchBar.android.clearFocus();
        }

    }
}
Run Code Online (Sandbox Code Playgroud)

然后我有了模板:

<Page.actionBar>
    <ActionBar title="Clientes"></ActionBar>
</Page.actionBar>

<StackLayout orientation="vertical" id="box-lista">
    <SearchBar hint="Buscar" cssClass="mh mv" id="barra-busca"></SearchBar>
</StackLayout>
Run Code Online (Sandbox Code Playgroud)

我的目标是获得搜索字段的自动焦点,但我无法获得界面元素.

javascript android typescript nativescript nativescript-angular

4
推荐指数
2
解决办法
6628
查看次数

本机脚本:套接字连接超时

我在Mac上,我想在USB-C连接的Android设备上运行我的应用。

我的第一步始终是删除node_modules,hook和platform文件夹以及package.lock.json文件。之后,我跑步tns build android。构建完成后,我将tns run android通过nativescript sidekick 运行或启动应用程序。

但现在总是这样结束:

项目成功建立。正在设备5B24000362上安装...已成功在标识为“ 5B24000362”的设备上安装。无法在设备上应用更改:5B24000362。错误是:套接字连接超时。

由于两天前我已经出现此错误,并且无法继续使用该应用程序,因此,我按照此升级说明更新了所有本机脚本和角度依赖项。更新之后,该应用程序再次运行。但是现在几个小时后,我再次遇到相同的错误(相同的应用)。工作结束后,我什至将应用程序推送到git存储库,然后重新克隆它,不起作用。

nativescript nativescript-angular

4
推荐指数
1
解决办法
1903
查看次数

Nativescript + Angular ScrollView滚动到结束侦听器

是否有任何回调可用于识别何时ScrollView滚动到最底部?在Nativescript文档中,仅scroll提及事件,但它仅提供有关当前滚动的X或Y线的信息.不确定这个事件是否对我有帮助,因为我的ScrollView身高是动态的.

nativescript angular2-nativescript nativescript-angular angular

4
推荐指数
1
解决办法
392
查看次数

NativeScript + Angular:如何安装和使用图标?

我正在尝试在适用于 iOS 和 Android 的NativeScript + Angular应用程序上使用图标。我尝试了不同的方式来设置图标,我使用了本教程,这个解决方案,我什至尝试使用材质插件nativescript-ngx-fonticon

所有这些方法都会给我这个错误

插件 nativescript-fontawesome 不包含在设备 [device-id] 上的预览应用程序中,并且无法工作。

现在,这是我当前的代码:

我的组件.组件.html

<Button text="&#xf810" class="fa" column="0"></Button>

应用程序.css

.fa {
    font-family: 'FontAwesome', fontawesome-webfont;
 }
Run Code Online (Sandbox Code Playgroud)

此外,我的app/fonts文件夹中有以下文件:

fontawesome-webfont.ttf

那么,出了什么问题呢?

谢谢

nativescript angular2-nativescript nativescript-angular angular nativescript-plugin

4
推荐指数
1
解决办法
2356
查看次数

nativescript |layouts 为 ngFor 循环创建 ui

,我尝试创建一个视图并且遇到了麻烦。我试图用 ngFor 创建一行图像,所以我不知道将在屏幕上显示的图像的执行数量,但需要它看起来像那样,如果有 3 张照片,它将在一行中,但是当第四张照片时图像将被添加,它将下降到一个新行在此处输入图片说明

谢谢你

nativescript angular2-nativescript nativescript-telerik-ui nativescript-angular

3
推荐指数
1
解决办法
238
查看次数

属性“ throw”在类型“ typeof Observable”上不存在

我学习用于开发android和ios应用程序的nativescript + angular.Iam工作和学习nativescript + angular的基本服务。在我的项目的post方法中,我在类型'typeof Observable'上没有错误'属性'throw'。我的代码是:

import { User } from "./user";
import { Config } from "../config";
import { Injectable } from "@angular/core";
import { Observable } from "tns-core-modules/ui/page/page";

@Injectable()
export class UserService {
    constructor(private http: Http) { }

    register(user: User) {
        let headers = new Headers();
        headers.append("Content-Type", "application/json");

        return this.http.post(
            Config.apiUrl + "Users",
            JSON.stringify({
                Username: user.email,
                Email: user.email,
                Password: user.password
            }),
            { headers: headers }
        )
            .catch(this.handleErrors);

    }

    handleErrors(error:Response)
    {
        console.log(JSON.stringify(error.json()));
        return Observable.throw(error);        
    }



} 
Run Code Online (Sandbox Code Playgroud)

nativescript-angular

3
推荐指数
2
解决办法
707
查看次数

预期有2个参数,但得到1.ts(2554)core.d.ts(8064,47):未提供'opts'的参数

错误

预期有2个参数,但得到1.ts(2554)core.d.ts(8064,47):未提供'opts'的参数。

代码来自NativeScript市场

https://play.nativescript.org/?template=play-ng&id=Hqp5UQ&v=3073

我已经逐字逐句地携带了代码,并且在导出类中遇到了错误

@ViewChild("password") password: ElementRef;
@ViewChild("confirmPassword") confirmPassword: ElementRef;
Run Code Online (Sandbox Code Playgroud)

有谁知道如何解决这个问题?

import { Component, ElementRef, ViewChild } from "@angular/core";
import { alert, prompt } from "tns-core-modules/ui/dialogs";
import { Page } from "tns-core-modules/ui/page";
import { RouterExtensions } from "nativescript-angular/router";

import { User } from "../shared/user.model";
import { UserService } from "../shared/user.service";

@Component({
    selector: "app-login",
    moduleId: module.id,
    templateUrl: "./login.component.html",
    styleUrls: ["./login.component.css"]
})
export class LoginComponent {
    isLoggingIn = true;
    user: User;
    processing = false;
    @ViewChild("password") password: ElementRef;
    @ViewChild("confirmPassword") confirmPassword: ElementRef;

    constructor(private …
Run Code Online (Sandbox Code Playgroud)

typescript nativescript nativescript-angular

3
推荐指数
1
解决办法
5019
查看次数

NativeScript / Angular-使用ngModel / FormBuilder时如何在开关上设置检查状态的样式?

考虑以下开关:

<Switch class="switch" formControlName="answer"></Switch>
Run Code Online (Sandbox Code Playgroud)

如果执行此操作,则仅在您尚未激活开关时才起作用,此后即使开关未激活,背景色也将始终相同:

.switch[checked=true] {
  background-color: #FE4A49;
  color: #FE4A49;
}
Run Code Online (Sandbox Code Playgroud)

如果我这样做:

.switch {
  background-color: #FE4A49;
  color: #FE4A49;
}
Run Code Online (Sandbox Code Playgroud)

这样,无论状态如何,背景都将始终相同。

将开关与angular的模型绑定一起使用时,样式设置开关的正确方法是什么?

css nativescript nativescript-angular angular

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

类型“Subscription”缺少类型“typeof Subscription”中的以下属性:prototype、EMPTY

import { Component, OnInit, OnDestroy, ViewChild, AfterViewInit, ChangeDetectorRef } from "@angular/core";
import { UIService } from "./shared/ui.service";
import { Subscription } from "rxjs";
import { RadSideDrawerComponent } from "nativescript-ui-sidedrawer/angular";
import { RadSideDrawer } from "nativescript-ui-sidedrawer";
Run Code Online (Sandbox Code Playgroud)

//这些是我的导入

@Component({
    selector: "ns-app",
    templateUrl: "./app.component.html"
})
export class AppComponent implements OnInit, OnDestroy, AfterViewInit {

    @ViewChild(RadSideDrawerComponent, { static: false }) drawerComponent: RadSideDrawerComponent;

    enteredChallenge: string[] = [];
    private drawerSub = Subscription; //I have put subscription here
    private drawer: RadSideDrawer;

    constructor (private uiService: UIService, private changeDetectionRef: ChangeDetectorRef) …
Run Code Online (Sandbox Code Playgroud)

nativescript-angular

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