skip to Main Content

I need to redirect to the page of a new application written in Angular and send data
Is it possible to transfer, for example, a token to the angular?

I tried to make a redirect to – http://localhost:4200/token/hrl4lhlhga – hrl4lhlhga <== token

const appRoutes: Routes = [
  {
    path: 'token/:value',
    component: TestComponent,
  }
];
export class TestComponent {
  @Input() value?: string;
}
bootstrapApplication(AppComponent, {
  providers: [
    provideRouter(appRoutes, withComponentInputBinding()),

But ‘value’ always undefined

ADDED 18.03

main.ts

bootstrapApplication(AppComponent, appConfig)
  .catch(err => console.error(err));

app.config.ts

export const appConfig: ApplicationConfig = {
  providers: [
    provideRouter(appRoutes, withDebugTracing(), withComponentInputBinding()),
    provideAnimations(),
    provideHttpClient(withInterceptorsFromDi()),
    importProvidersFrom(BrowserModule, ToastModule, InputTextModule, InputNumberModule, InputTextareaModule, MatCardModule, CommonModule, FormsModule, MenubarModule, DropdownModule, DragDropModule, FieldsetModule, CardModule, PanelModule, ButtonModule, FlexLayoutModule, TagModule, AccordionModule, ScrollPanelModule, TableModule),
    BackEndService, DialogService, MessageService, ApplicationService, 
  ]
}

I have added withDebugTracing and for http://localhost:4200/token/hrl4lhlhga now I get

ERROR Error: NG04002: Cannot match any routes. URL Segment: 'token/hrl4lhlhga'

The paths appear to have been loaded, but for some reason Angular cannot establish that such a path exists. Maybe something conflicts in my configuration or I described everything incorrectly

2

Answers


  1. Chosen as BEST ANSWER

    I found the reason why this happened. One of my components had a RouterTestingModule imported (now deprecated). Therefore, all my routes were rewritten and cleaned up. I just removed this from the import and now everything works as expected.


  2. in provideRouter you should inject routes not appRoutes

      bootstrapApplication(AppComponent, {
      providers: [
        provideRouter(routes, withComponentInputBinding()),
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search