child routing issue in Angular 4

BraveBoy

i implemented child route but its giving me error and i am not able to open even my parent page which i mentioned in code, here is my code, error is mentioned at the end

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

@Component({
    template:`<div style="width:350px;hight:200px;background-color:#00ff00">
                <h1>Create Places</h1>
               </div>              
                <a [routerLink]="['/placeDetail']">PlaceDetail</a>          
              <div>                
                <router-outlet></router-outlet>
              </div>
              `
})

export class PlaceComponent{}
`

import { ModuleWithProviders }  from '@angular/core';
import { Routes, RouterModule } from '@angular/router';

import { DashboardComponent }   from '../app/components/dashboard.component';
import {NeighbourhoodComponent} from '../app/components/neighbourhood.component';
import {UserProfileComponent} from '../app/components/userProfile.component';
import {PlaceComponent} from '../app/components/place.component';
import {PlaceDetailComponent} from '../app/components/placeDetail.component';


const appRoutes: Routes = [
  {
    path: '',
    redirectTo: 'dashboard',
    pathMatch: 'full'
  },
  {
    path: 'dashboard',
    component: DashboardComponent
  },
  {
    path:'neighbourhood',
    component:NeighbourhoodComponent
  },
  {
    path:'userprofile',
    component:UserProfileComponent
  },
  {
    path:'place',
    component:PlaceComponent,
    children:[
        {
          path:'placeDetail',
          component:PlaceDetailComponent
        }
      ]
  }
];

export const routing: ModuleWithProviders = RouterModule.forRoot(appRoutes);

once i will click on link it should go to placeDetailComponent but it is giving me error

EXCEPTION: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'place'

BraveBoy

issue solved, i had Angular 2.1, just updated to 5 and it is working.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related