1

我正在尝试用 Angular 开发原生脚本中的应用程序。
我想使用telerik-ui的侧边抽屉,就像过滤面板一样,我将在主要内容文本区域中显示一些数据。问题是我启动代码时没有错误,除了没有sideDrawer的事实全部。我不知道如何调试它。
我目前正在尝试为我的应用程序使用这个示例(仅文件名称):
http ://docs.telerik.com/devtools/nativescript-ui/Controls/Angular/SideDrawer/getting-started

filter.component.html:

<RadSideDrawer showOverNavigation="true" tkExampleTitle tkToggleNavButton class="page">
    <StackLayout tkDrawerContent class="sideStackLayout">
        <StackLayout class="sideTitleStackLayout">
            <Label text="Navigation Menu"></Label>
        </StackLayout>
        <StackLayout class="sideStackLayout">
            <Label text="Primary" class="sideLabel sideLightGrayLabel"></Label>
            <Label text="Social" class="sideLabel"></Label>
            <Label text="Promotions" class="sideLabel"></Label>
            <Label text="Labels" class="sideLabel sideLightGrayLabel"></Label>
            <Label text="Important" class="sideLabel"></Label>
            <Label text="Starred" class="sideLabel"></Label>
            <Label text="Sent Mail" class="sideLabel"></Label>
            <Label text="Drafts" class="sideLabel"></Label>
        </StackLayout>
        <Label text="Close Drawer" color="lightgray" padding="10" style="horizontal-align: center" (tap)="onCloseDrawerTap()"></Label>
    </StackLayout>
    <StackLayout tkMainContent>
        <Label [text]="mainContentText" textWrap="true" class="drawerContentText"></Label>
        <Button text="OPEN DRAWER" (tap)="openDrawer()" class="drawerContentButton"></Button>
    </StackLayout>
</RadSideDrawer>

filter.component.ts:

import { Component, ViewChild, OnInit, AfterViewInit, ChangeDetectorRef } from "@angular/core";
import { Page } from "ui/page";
import { ActionItem } from "ui/action-bar";
import { Observable } from "data/observable";
import { RadSideDrawerComponent, SideDrawerType } from "nativescript-telerik-ui/sidedrawer/angular";
import { RadSideDrawer } from 'nativescript-telerik-ui/sidedrawer';

@Component({
    moduleId: module.id,
    selector: "tk-sidedrawer-getting-started",
    templateUrl: 'filter.component.html',
    styleUrls: ['filter.component.css']
})
export class SideDrawerGettingStartedComponent implements AfterViewInit, OnInit {
    private _mainContentText: string;

    constructor(private _changeDetectionRef: ChangeDetectorRef) {
    }

    @ViewChild(RadSideDrawerComponent) public drawerComponent: RadSideDrawerComponent;

    private drawer: RadSideDrawer;

    ngAfterViewInit() {
        this.drawer = this.drawerComponent.sideDrawer;
        this._changeDetectionRef.detectChanges();
    }

    ngOnInit() {
        this.mainContentText = "SideDrawer for NativeScript can be easily setup in the HTML definition of your page by defining tkDrawerContent and tkMainContent. The component has a default transition and position and also exposes notifications related to changes in its state. Swipe from left to open side drawer.";
    }

    get mainContentText() {
        return this._mainContentText;
    }

    set mainContentText(value: string) {
        this._mainContentText = value;
    }

    public openDrawer() {
        this.drawer.showDrawer();
    }

    public onCloseDrawerTap() {
       this.drawer.closeDrawer();
    }
}  

过滤器.module.ts:

import { NgModule, NO_ERRORS_SCHEMA } from "@angular/core";
import { NativeScriptModule } from "nativescript-angular/nativescript.module";
import { NativeScriptUISideDrawerModule } from "nativescript-telerik-ui/sidedrawer/angular";


import { FilterRoutingModule } from "./filter.routing";
import { SideDrawerGettingStartedComponent } from "./filter.component";

@NgModule({
    imports: [
        NativeScriptModule,
        FilterRoutingModule,
        NativeScriptUISideDrawerModule
    ],
    declarations: [
        SideDrawerGettingStartedComponent
    ],
    schemas: [
        NO_ERRORS_SCHEMA
    ]
})
export class FilterModule { }  

filter.routing.ts:

    import { NgModule } from "@angular/core";
    import { Routes } from "@angular/router";
    import { NativeScriptRouterModule } from "nativescript-angular/router";

    import { SideDrawerGettingStartedComponent } from "./filter.component";

    const routes: Routes = [
        { path: "filter", component: SideDrawerGettingStartedComponent }
    ];

    @NgModule({
        imports: [NativeScriptRouterModule.forChild(routes)],
        exports: [NativeScriptRouterModule]
    })
    export class FilterRoutingModule { }  

filter.component.css:

 button {
    font-size: 15;
    horizontal-align: center;
}

.mainContentText {
    font-size: 13;
    padding: 10;
}

.mainContentButton {
    margin: 10;
    horizontal-align: left;
}

.drawerContentButton {
    color: yellowgreen;
}

.sideStackLayout {
    background-color: gray;
}

.sideTitleStackLayout {
    height: 56;
    text-align: center;
    vertical-align: center;
}

.sideLabel {
    padding: 10;
}

.sideLightGrayLabel {
    background-color: lightgray;
} 

当我进入这个过滤页面时,侧边抽屉根本没有出现。我的应用程序的结构类似于这个:https ://github.com/NativeScript/sample-Groceries

任何帮助,将不胜感激。

4

2 回答 2

0

你有任何例外吗?你确定你的按钮标签有效吗?否则我可以在我的项目上使用它:我给了 RadSideDrawer 一个 ID

<RadSideDrawer #drawer showOverNavigation="true" tkExampleTitle tkToggleNavButton class="page">

并像这样使用@ViewChild:

@ViewChild('drawer') public drawerComponent: RadSideDrawerComponent;

如果您对此有解决方案,请告诉我。

于 2017-08-19T21:58:01.370 回答
0

我设法通过在我的 package.json 文件中添加一些依赖项来解决我的问题。
为此,我创建了一个新的空白生成项目并安装了 RadSideDrawer,我比较了我拥有的依赖项并升级并添加了其中一些(例如,我的依赖项列表中没有 @angular/animations)

于 2017-08-21T15:33:57.920 回答