android - 如何添加侧抽屉? [Nativescript + Angular]

标签 android angularjs nativescript angular2-nativescript

在主模块中我添加了这个:

import {SIDEDRAWER_DIRECTIVES} from "nativescript-telerik-ui/sidedrawer/angular";
...
declarations: [
        SIDEDRAWER_DIRECTIVES,
        AppComponent,
        ...AppComponents
]

app.component.html 的 xml 部分:

<RadSideDrawer [drawerLocation]="currentLocation" tkExampleTitle tkToggleNavButton>
    <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>
    </StackLayout>
    <StackLayout tkMainContent>
        <Label [text]="mainContentText" textWrap="true" class="drawerContentText"></Label>
        <Button text="OPEN DRAWER" (tap)=openDrawer()></Button>
    </StackLayout>
</RadSideDrawer>

当我尝试运行它时出现错误:

An uncaught Exception occurred on "main" thread. com.tns.NativeScriptException: Calling js method onCreateView failed

TypeError: Cannot read property 'android' of undefined File: "file:///data/data/org.nativescript.nativescript/files/app/tns_modules/nativescript-telerik-ui/sidedrawer/sidedrawer.js, line: 91, column: 39

StackTrace: Frame: function:'RadSideDrawer.initOldDrawer', file:'file:///data/data/org.nativescript.nativescript/files/app/tns_modules/nativescript-telerik-ui/sidedrawer/sidedrawer.js', line: 91, column: 40 Frame: function:'RadSideDrawer._createUI', file:'file:///data/data/org.nativescript.nativescript/files/app/tns_modules/nativescript-telerik-ui/sidedrawer/sidedrawer.js', line: 147, column: 18 Frame: function:'View._onContextChanged', file:'file:///data/data/org.nativescript.nativescript/files/app/tns_modules/ui/core/view.js', line: 202, column: 14 Frame: function:'View._onAttached', file:'file:///data/data/org.nativescript.nativescript/files/app/tns_modules/ui/core/view.js', line: 1

有人知道什么是问题吗?

最佳答案

  • 导入:

从'nativescript-telerik-ui/sidedrawer/angular'导入{NativeScriptUISideDrawerModule};

  • 将其添加到您的导入中:

导入:[ NativeScriptUISideDrawerModule, ... ]

现在,您的侧抽屉应该可以正常工作了。

关于android - 如何添加侧抽屉? [Nativescript + Angular],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42283061/

相关文章:

android - 自定义 ExpandableListview Android

javascript - 如何在指令之外传递 'scope' 参数

nativescript - 在 NativeScript 中检测应用程序不活动/空闲超时

css - NativeScript/Angular - 如何导入全局样式?

html - Angularjs:单个 html 中的多个部分?

javascript - 带有 NativeScript 的 Facebook Flow(而不是 TypeScript)

android - 通知访问安卓?如何使用它?

android - Jitpack doent 构建项目

android - 如何清除堆?

angularjs - AngularJs : do I require $scope in my controller for this?