我正在为 NativeScript 使用 Telerik UI。但是,抽屉的行为很奇怪,Button 上的 TAP 手势可以正常工作,但是,当我将 TAP 手势添加到 Label 时,它就不起作用了。
我添加
(点击)=openDrawer()
标签上。但是当我单击标签时,什么也没有发生。
import { Component, ElementRef, ViewChild, Inject, OnInit, ChangeDetectorRef } from "@angular/core";
import { View } from "ui/core/view";
import { RadSideDrawer } from "nativescript-telerik-ui-pro/sidedrawer";
import { Page } from "ui/page";
import { ActionItem } from "ui/action-bar";
import sideDrawerModule = require('nativescript-telerik-ui-pro/sidedrawer');
import * as ObservableModule from "data/observable";
import { RadSideDrawerComponent, SideDrawerType } from "nativescript-telerik-ui-pro/sidedrawer/angular";
@Component({
moduleId: module.id,
selector: "mp-app",
templateUrl:'./testdrawer.html',
})
export class TestComponent extends ObservableModule.Observable implements OnInit {
public mainContentText: string = "Hello World";
constructor( @Inject(Page) private page: Page, private _changeDetectionRef: ChangeDetectorRef) {
super();
}
@ViewChild(RadSideDrawerComponent) public drawerComponent: RadSideDrawerComponent;
private drawer: SideDrawerType;
ngAfterViewInit() {
this.drawer = this.drawerComponent.sideDrawer;
this._changeDetectionRef.detectChanges();
}
ngOnInit() {
this.set("mainContentText", "SideDrawer for NativeScript can be easily setup in the XML definition of your page by defining main- and drawer-content. 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.");
}
public openDrawer() {
alert('openDrawer');
this.drawer.showDrawer();
}
public closeDrawer() {
alert('close drawer');
this.drawer.closeDrawer();
}
}
<!-- >> angular-sidedrawer-getting-started -->
<RadSideDrawer #drawer>
<template drawerSide>
<StackLayout 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" (tap)=closeDrawer()></Label>
<Label text="Starred" class="sideLabel"></Label>
<Label text="Sent Mail" class="sideLabel"></Label>
<Label text="Drafts" class="sideLabel"></Label>
</StackLayout>
</StackLayout>
</template>
<template drawerMain>
<StackLayout>
<Label [text]="mainContentText" textWrap="true" (tap)=openDrawer() class="drawerContentText"></Label>
<Button text="OPEN DRAWER" (tap)=openDrawer()></Button>
</StackLayout>
</template>
</RadSideDrawer>
<!-- << angular-sidedrawer-getting-started -->