NativeScript应用路由器错误。我的应用程式无法启动

时间:2018-08-13 14:24:00

标签: nativescript router-outlet

运行我的应用程序时出现错误。

我的应用程序构建如下: app-component应该导航到app-routes并从那里导航到pages-component。 pages-component模板是“ router-outlet”,它导航到在视图之间导航的pages-routes。

我是这样的:

主要应用程序组件:

import { Component } from "@angular/core";
import { PagesComponent } from '~/pages/pages.component'

@Component({
    selector: "ns-app",
    template: "<router-outlet></router-outlet>"
})

export class AppComponent { }

主要应用路线:

import { PagesComponent } from "~/pages/pages.component";
import { LoginComponent } from "~/pages/login/login.component";
import { RegisterComponent } from "~/pages/register/register.component";
import { AuthGuard } from "~/@shared/services/auth-guard.service";
import { TaskListComponent } from "~/pages/task-list/task-list.component";


export const AUTH_PROVIDERS = [
    AuthGuard
]; 
export const APP_ROUTES = [

    { path: "", redirectTo: "/pages", pathMatch: "full" },
    { path: "**", redirectTo: "" },

    ];

pages-component:

import { OnInit, Component } from "@angular/core";
import { RouterExtensions } from "nativescript-angular/router";
import { Router } from "@angular/router";

@Component({
    moduleId: module.id,
    selector: "pages",
    template: "<router-outlet></router-outlet>"
})
export class PagesComponent implements OnInit {

    constructor(private routerExtensions: RouterExtensions, private router: 
Router) {

    }

    ngOnInit(): void {
    }


}

pages-routes:

import { NativeScriptRouterModule } from "nativescript-angular/router";
import { ModuleWithProviders } from "@angular/core";
import { PagesComponent } from "~/pages/pages.component";
import { LoginComponent } from "~/pages/login/login.component";
import { RegisterComponent } from "~/pages/register/register.component";
import { AuthGuard } from "~/@shared/services/auth-guard.service";
import { TaskListComponent } from "~/pages/task-list/task-list.component";



const PAGES_ROUTES = [
            {path: "pages", component: PagesComponent, children: [
            { path: "login", component: LoginComponent },
            { path: "register", component: RegisterComponent },
            { path: "task-list", canActivate: [AuthGuard], component: 
TaskListComponent },
            { path: "", redirectTo: "/task-list", pathMatch: "full" },

        ]
    },

];
//, canActivate:[AuthGuard]
export const PagesRoutingModule: ModuleWithProviders = 
NativeScriptRouterModule.forRoot(PAGES_ROUTES);

我遇到的错误:

The Error Screenshot

您认为可能是什么问题?我想念什么吗?

谢谢!

0 个答案:

没有答案