Angular 4无法匹配任何路由,使用%2F

时间:2017-08-30 16:08:48

标签: angular angular-router

我在angular 4项目中遇到路由问题。 当我尝试导航到像ticketBlocks/new这样的路径时,我看到了这个错误:

  

错误:未捕获(在承诺中):错误:无法匹配任何路由。网址   细分:'ticketBlocks%2Fnew'

Angular逃脱'/'并且当然不匹配,是否可以在没有逃脱的情况下使用此路径?

这是我的 app.routing

export const AppRoutes: Routes = [
.
.
.
 {
   path: 'ticketBlocks/new',
   loadChildren: './ticket-blocks/ticket-block-new/ticket-block-
   new.module#TicketBlockNewModule'
  },
.
.

我的侧边栏

export const ROUTES: RouteInfo[] = [{
.
.
.
{
    path: '/',
    title: 'Magazzino',
    type: 'sub',
    icontype: 'assignment_turned_in',
    children: [
        { path: 'ticketBlocks/new', title: 'Nuovi blocchi', ab: 'NB' },
        { path: 'ticketBlocks/movements', title: 'Spostamenti', ab: 'SP' }
    ]
},

sidebar.ts

export class SidebarComponent implements OnInit, AfterViewInit {
    public menuItems: any[];

    ngOnInit() {
        let isWindows = navigator.platform.indexOf( 'Win' ) > -1 ? true : false;
        if ( isWindows ) {
            // if we are on windows OS we activate the perfectScrollbar function
            const $sidebar = $( '.sidebar-wrapper' );
            $sidebar.perfectScrollbar();
        }
        this.menuItems = ROUTES.filter( menuItem => menuItem );
        isWindows = navigator.platform.indexOf( 'Win' ) > -1 ? true : false;

        if ( isWindows ) {
            // if we are on windows OS we activate the perfectScrollbar function
            $( '.sidebar .sidebar-wrapper, .main-panel' ).perfectScrollbar();
            $( 'html' ).addClass( 'perfect-scrollbar-on' );
        } else {
            $( 'html' ).addClass( 'perfect-scrollbar-off' );
        }
    }

这是 sidebar.html

<li routerLinkActive="active" *ngFor="let menuitem of menuItems">
<!--If is a single link-->
<a [routerLink]="[menuitem.path]" *ngIf="menuitem.type === 'link'">
<i class="material-icons">{{menuitem.icontype}}</i>
<p>{{menuitem.title}}</p>
</a>
</li>

0 个答案:

没有答案