2017-06-07 18 views
0

この例を使用して角度とNativeScript RadSideDrawerを使用しよう: https://gist.github.com/NathanWalker/e8f4f7c42af04fc725764a9867936e3dNativescript RadSideDrawerルーティング問題

Iルート/ホーム/フィードに移動したときに次のルーティングエラーが発生:

JS: Unhandled Promise rejection: Cannot find primary outlet to load 'FeedComponent' ; Zone: <root> ; 
Task: Promise.then ; Value: Error: Cannot find primary outlet to load 'FeedComponent' Error: Cannot find primary outlet to load 'FeedComponent' 

その経路サイド引き出しを使用しないでください(IEは「家庭」の親を持っていません)うまく動作します。

app.component.ts(ルートコンポーネント)

export const routes = [ 
    { path: 'home', component: HomeComponent, 
    children: [ 
     { path: 'feed', component: FeedComponent } <-- this route fails 
    ] 
    }, 
    { path: 'login', children: [ 
    { path: '', component: LoginComponent }, <-- these routes work 
    { path: 'type', component: ChooseTypeComponent } <-- these routes work 
    ]} 
]; 

home.component.ts

+0

ないあなたはapp.component HTMLに 'ページ-ルータoutlet'周り' StackLayout'を追加した理由を確認してください。それは必須ではなく、実際には物事を破ることができます。 –

答えて

1
<ActionBar title="Plant Powered Community"> 
    <ActionItem (tap)="toggle()"> 
    <!-- example: using font-awesome for hamburger menu but you can use whatever you'd like --> 
    <Button class="fa" text="&#xf0c9;"></Button> 
    <!-- however in your project, would be easier to use this plugin: https://github.com/NathanWalker/nativescript-fonticon --> 
    </ActionItem> 
</ActionBar> 
<RadSideDrawer #drawer [transition]="sideDrawerTransition" selectionBehavior="None"> 
    <StackLayout tkDrawerContent> 
    <!-- anything you want in drawer --> 
    <!-- for example: --> 
    <!-- you want options {exact: true} on the first one because otherwise it would be considered active when 'Other Page' in active as well --> 
    <Button text="Home" [nsRouterLink]="['/home']" nsRouterLinkActive="active" [nsRouterLinkActiveOptions]="{exact:true}"></Button> 
    <Button text="Other Page" [nsRouterLink]="['/home/otherPath']" nsRouterLinkActive="active"></Button> 
    </StackLayout> 
    <StackLayout tkMainContent> 
    <router-outlet></router-outlet> 
    </StackLayout> 
</RadSideDrawer> 

import { Component } from '@angular/core'; 

@Component({ 
    selector: 'ppc-app', 
    template: '<StackLayout><page-router-outlet></page-router-outlet></StackLayout>', 
    styleUrls: [] 
}) 
export class AppComponent {} 

app.routes.tsはおそらく構造でありますファイルapp.routes.ts

export const APP_ROUTES: Routes = [ 
{ 
    path: '', 
    redirectTo: '/home/feed', 
    pathMatch: 'full' 
}, 
{ 
    path: "home", 
    component: HomeComponent, 
     children: [ 
      {path: "login", component: LoginComponent}, 
      {path: 'type', component: ChooseTypeComponent }, 
      {path: 'feed', component: FeedComponent } 
     ] 
}, 

];

単純なRadSideDrawerの例を作成しました。役立つかどうかを確認しました。

https://github.com/simonettoa/nativescript-RadSideDrawer