Нет общих свойств с типом "Маршрут" - PullRequest
0 голосов
/ 10 мая 2018

Const маршруты выделяются красным и выдает следующую ошибку:

Type "({path: string; component: Route [];} | {path: string;
component: Route []; canActivate: (typeof ..." can not be assigned for
type "Route []".

Type "{path: string; component: Route [];} | {path: string; component:
Route []; canActivate: (typeof ..." can not be assigned to the "Route"
type.

The "{path: string; component: Route [];}" type can not be assigned to
the "Route" type.

The property types of the "component" are incompatible.

The "Route []" type can not be assigned for type "type <any>".


The "apply" property is not present in the type "Route []".

и так далее ...

Как я могу это исправить?

import { Routes } from '@angular/router';

import { SignInRoutes } from '../layout/sign-in/index';
import { LayoutRoutes } from '../layout/index';

import { SignInComponent } from '../layout/sign-in/sign-in.component';

import { AuthGuard } from '../shared/guards/auth.guard';

export const routes: Routes = [

{ path: 'sign_in',   component: SignInRoutes },
{ path: 'layout',   component: LayoutRoutes, canActivate: [AuthGuard] },
{ path: '**', component: SignInComponent }

];

Ответы [ 2 ]

0 голосов
/ 10 мая 2018

Я приложил пример.

const recipesRoutes : Routes = [
    { path: 'recipes', component: RecipesComponent, children: [
    { path: '', component: RecipeStartComponent },
    { path: 'new', component: RecipeEditComponent, canActivate: [AuthGuard] },
    { path: ':id', component: RecipeDetailComponent },
    { path: ':id/edit', component: RecipeEditComponent, canActivate: [AuthGuard] },
  ] },
];

Надеюсь, это поможет !!

0 голосов
/ 10 мая 2018

Похоже, вы назначаете маршруты для свойства компонента, которое не допускается.Если вы пытаетесь достичь вложенных маршрутов, вам следует использовать свойство children.Пожалуйста, обратитесь к учебнику для более информация

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...