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
– Lucas Vellido
Have you tried using routerLink this way?
<a routerLink="novoevento">
– Albertt Santos
I tried, same thing :/
– Tiago Silveira
@Lucasvellido, I think the problem really is in the Observable, it’s passing as null, but the code is right :/ I think rsrs
– Tiago Silveira
What version of rxjs are you using? Instead of
import {Observable} from 'rxjs'
tries to makeimport { throwError } from 'rxjs'
and in the code usereturn throwError(errorMessage)
– Leonardo Lima
@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.
– Tiago Silveira
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.
– Tiago Silveira
Would not be
<a [routerLink]="['eventos/novoevento']">
?– Marconi
Try to import the
RouterModule
of@angular/router
and putRouterModule.forRoot()
in your import ofAppComponent
. By imports, this module is not being imported.– Victor Henrique
You can share your Eventoscomponent and the module where you declare them?
– Gabriel Ferreira