Make Telerik Sidedrawer in all views

I successfully got a Telerik side box working in one view, but I was stuck with turning it into a component that I can use around the world.

I would like to avoid copying and pasting it into all kinds, so my question is how to turn it into a reusable component.

+4
source share
1 answer

So when you use page-router-outlet

<page-router-outlet></page-router-outlet> - , (, , - , ).

, , , :

<RadSideDrawer #drawer>
    <StackLayout tkDrawerContent class="sideStackLayout">
        <StackLayout class="sideTitleStackLayout">

            <ScrollView>
                <StackLayout class="sideStackLayout">

                <!-- content of menu -->

                </StackLayout>
            </ScrollView>
        </StackLayout>

    </StackLayout>
    <StackLayout tkMainContent>
        <ActionBar title="">
              <!-- this is your action bar content -->
        </ActionBar>
        <ng-content></ng-content>
    </StackLayout>
</RadSideDrawer>

TS SideDrawer. , ( , @Component , - components/header/header.component.html your-header)

@Component({
    selector: "your-header",
    templateUrl: "components/header/header.component.html",
    styleUrls: ['components/header/header.css'],
})

( login) HeaderComponent

import {HeaderComponent} from "../../header/header.component";

@Component({
    selector: "login-page",
    templateUrl: "components/user/login/login.component.html",
    styleUrls: ['components/user/login/login.css'],
    directives: [HeaderComponent]
})

login.component.html

<your-header>
    <StackLayout class="content">
        <label class="h1 left" text="Please Login"></label>
    </StackLayout>
</your-header>

, sidedrawer (ng-content SideDrawer), angular.

- Sidedrawer .

import {nativeScriptBootstrap} from "nativescript-angular/application";
import {nsProvideRouter} from "nativescript-angular/router";
import {RouterConfig} from "@angular/router";
import {AppComponent} from "./app.component";
import {SIDEDRAWER_PROVIDERS} from "nativescript-telerik-ui/sidedrawer/angular";

import {LandingComponent} from "./components/landingPage/landing.component";
import {LoginComponent} from "./components/user/login/login.component";



import {ExperimentalComponent} from "./components/experimental/experimental.component";


export const AppRoutes: RouterConfig = [
    { path: "", component: LandingComponent },
    { path: "login", component: LoginComponent },

]

nativeScriptBootstrap(AppComponent, [
    [nsProvideRouter(AppRoutes, {})],
    SIDEDRAWER_PROVIDERS,
], { startPageActionBarHidden: true });

- , , SideDrawer - , ( html ng-content)

, 1.3.x SideDrawer, , 1.4.x , , .

, SideDrawer, , ( SideDrawer ). , SideDrawer - .

, , <your-header variable="variableValue">. align ActionBar.

+4

Source: https://habr.com/ru/post/1656117/


All Articles