Daughter Routes in Angular

Asked

Viewed 319 times

0

I have a daughter route that opens a component, the component is not loaded, but the url yes what can be?

App Routes.ts

import { Routes } from '@angular/router'
import { HomeComponent } from './home/home.component'
import { EventosComponent } from './eventos/eventos.component';
import { MeusDadosComponent } from './meus-dados/meus-dados.component';
import { NovoeventoComponent } from './eventos/novoevento/novoevento.component';
export const ROUTES: Routes = [
{path: '', component: HomeComponent},
{path: 'home', component: HomeComponent},
{path: 'eventos', component: EventosComponent,
     children: [
         {path: 'novoevento', component: NovoeventoComponent},
     ]},
{path:'meus-dados', component: MeusDadosComponent }
]

Marking calling the component:

 <a [routerLink]="['novoevento']"> 
                      <button type="button" class="btn btn-info round button-full-width" style="margin-right: 20px !important">
                      <span class="glyphicon glyphicon-plus "></span> Novo Evento</button>
                    </a>

On the console shows no more errors

  • Apparently this error is not about the routes, but rather the import of the Observable, take a look at that link

  • Have you tried using routerLink this way? <a routerLink="novoevento">

  • I tried, same thing :/

  • @Lucasvellido, I think the problem really is in the Observable, it’s passing as null, but the code is right :/ I think rsrs

  • What version of rxjs are you using? Instead of import {Observable} from 'rxjs' tries to make import { throwError } from 'rxjs' and in the code use return throwError(errorMessage)

  • @Leonardolima, thank you, solved the part of the Observable, but unfortunately the component is still not being loaded, I found it strange that he refused a Connection at door 3000, but I’m not even touching that door.

  • I understood what the error was, when loading the event component, it gives a get to a json server, and this json server was offline, now I climbed it and the error is gone, but the problem of not displaying the NOVOEVENTO component, continues.

  • Would not be <a [routerLink]="['eventos/novoevento']"> ?

  • Try to import the RouterModule of @angular/router and put RouterModule.forRoot() in your import of AppComponent. By imports, this module is not being imported.

  • You can share your Eventoscomponent and the module where you declare them?

Show 5 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.