Axel
Axel

Reputation: 306

nativescript angular sidedrawer not appearing without errors

I am trying to develop an application in nativescript with angular.
I want to use the side drawer from telerik-ui like a filtering panel for some data I will display in the main content text area.The problem is that I have no error when I launch my code except the fact that there is no sideDrawer at all. I don't know how to debug it.
I am currently trying to use this example a bit modified for my application (only names of the files):
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();
    }
}  

filter.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;
} 

The side drawer doesn't appear at all when I go to this filtering page. The structure of my application is similar to this one : https://github.com/NativeScript/sample-Groceries

Any help would be appreciated.

Upvotes: 1

Views: 499

Answers (2)

Axel
Axel

Reputation: 306

I managed to resolve my problem by adding some dependencies in my package.json file.
To do that I created a new blank generated project and installed the RadSideDrawer and I compared the dependencies I had and upgraded and added some of them (I didn't have @angular/animations in my dependency list for instance)

Upvotes: 0

RoalSky
RoalSky

Reputation: 31

do you get any exeptions? are you sure that you Button tab works? Otherwise I got this to work on my project: I gave the RadSideDrawer an ID

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

and used the @ViewChild like this:

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

Let me know if you got a solution for this.

Upvotes: 0

Related Questions