Questions tagged routes

Explore the latest questions and answers asked by our top developers.

Angular routing, internationalization, and deployment

We have an Angular 12 application that has multiple modules like ShippingModule, ReceivingModule, etc. We have set up routes appropriately and can access each module with simple paths like localhost:4200/Shipping and localhost:4200/Receiving. We have internationalized it and are looking to deploy it to an nginx server. When we do our build, the dist directory contains […]

By Josh
Categorized as angular, internationalization, nginx, routes Tagged , , ,

Angular Testing Uncaught Error: Uncaught (in promise): TypeError: Cannot read properties of null (reading ‘params’)

I have problem with testing my component. The main problem is when I run fixture.detectChanges(). When I do not fire it, all tests pass without any problems. This is the tests: describe(“simple HTML”, () => { // beforeEach(() => { // fixture.detectChanges(); // }); it(‘should be created’, () => { expect(component).toBeTruthy(); }); it(“Component should render […]

Angular query param with parenthesis?

I have a simple Angular app that uses a query param from the router as follows: const routes: Routes = [{ path: ”, component: DefaultComponent }, { path: ‘:uname’, component: ProductDisplayComponent }]; This works great and I can access the ‘product’ "uname" as follows: let prodId = params.get(‘uname’) The issue is that some of the […]

By M Will
Categorized as angular, parameters, routes, url Tagged , , ,

routing in angular 12

I have used angular 12 in VSCode and Web Api 2 to develop my application. my routing looks like this const routes: Routes = [ { path: ”, component: HomeComponent, canActivate: [AuthGuard] }, { path: ‘home’, component: HomeComponent, canActivate: [AuthGuard] }, { path: ‘login’, component: LoginComponent }, …….// other routes in the application ]; @NgModule({ […]

By DotNetBeginner
Categorized as angular, routes Tagged ,

redirecting angular routing full pathmatch

I want use route like this /home/games how can i do it? this is my code but it isnt work please check const routes: Routes = [ {path: ‘home’,children:[ {path:’games’,component:GamesComponent}, {path:’apps’,component:AppsComponent}, ]}, ] @NgModule({ imports: [RouterModule.forRoot(routes)], exports: [RouterModule] }) export class AppRoutingModule { } Source: Angular Questions

By Agata
Categorized as angular, javascript, routes, typescript Tagged , , ,

Angular routing issue I don’t know what is missing

1.main file import { NgModule } from ‘@angular/core’; import { BrowserModule } from ‘@angular/platform-browser’; import { AppRoutingModule } from ‘./app-routing.module’; import { BlogpostModule } from ‘./blogpost/blogpost.module’; import { CmspageModule } from ‘./cmspage/cmspage.module’; import { OwlModule } from ‘ngx-owl-carousel’; import { AppComponent } from ‘./app.component’; import { HeaderComponent } from ‘./header/header.component’; import { FooterComponent } from […]

By Nimesh patel
Categorized as angular, children, main, routes Tagged , , ,

Angular Routing Not Found Component issue with Javascript files root directory

I’m having a strange issue with some javascript files in my index.html file. I recently added a Not Found Component to my project by adding the following route: { path: ‘**’, component: NotFoundComponent }, My Not Found Component works great if I add text to the end of the url. But if I add a […]

By Noel
Categorized as angular, javascript, routes Tagged , ,

Angular – Dynamic routing with router param vaiable

I want to do something like this in my routing.module.ts (see lines marked by–>) export const routes: Routes = [ path: ‘test/:action’, component: CreateComponent, –> canActivate: ‘:action’ == ‘read’ ? [Guard1] : [Guard1, Guard2], data: { –> screenAction: ‘:action’ == ‘read’ ? ‘read’ : ‘:action’, } ] I have to use the variable :action because […]

Losing url when routing in angular

Im having difficulties with routing in angular in certain project. Here is the function from certain component. After subscribing to currentCounter$ stream and taking value from it I need to pass it down to router, which takes me to another component. onEditAutomaticCounter() { this.isAutomaticCounterEditing = true; this.counterSubscription = this.currentCounter$.pipe(take(1)).subscribe((currentCounter) => { console.log(currentCounter); this.router.navigate([‘search’, ‘AutomaticCounter’, currentCounter.Id], […]

By Bartek Ostrowski
Categorized as angular, routes Tagged ,

ANGULAR – Specify route navigation on back button press

I want to "override" back button press navigation. When a user clicks back button on a browser I want to navigate him to the specific page (rather than the previous one). I tried with these: @HostListener(‘window:popstate’, [‘$event’]) onPopState(event: any) { console.log(‘Back button pressed’); this.router.navigate([‘/test’]); } This solution first navigates to the test.html and immediately after […]

By Domagoj Hamzi
Categorized as angular, navigation, routes, typescript Tagged , , ,
1 2 3 49

Still Have Questions?

Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us