Questions tagged angular-routing

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

Hiding url path in angular

I am building a route in angular as show below: const routes: Routes = [ {path:’home’, component: HomeComponent}, {path:”, redirectTo: ‘home’, pathMatch: ‘full’}, {path:’**’, redirectTo: ‘home’, pathMatch: ‘full’} ]; But when I open the webpage like http://localhost:4200/, it redirects to http://localhost:4200/home, which is the expected behavior, but I want to hide the /home at the […]

By Ankit Kathait
Categorized as angular, angular-routing Tagged ,

Unit testing of routing for nested components in Angular

I am developing unit tests for angular application which works with lazy loading design pattern. This is how a routing looks inside lazy loaded module: export const adminRoutes: Routes = [ { path: ”, component: AdminDashboardComponent, children: [ { path: ‘layout’, component: AdminLayoutComponent, canActivate: [GuestGuard], children: [ { path: ‘notes’, component: ListNotesComponent, }, { path: […]

Angular using a fragment and child in URL

I am trying to use a router fragment as part of a username to allow users to copy a link to their "dashboard". I also want to have some children of that dashboard which would be able to control the content shown on the page, but keep the same page wrapper. I am trying to […]

By ntgCleaner
Categorized as angular, angular-routing Tagged ,

Route parameters – subscribe method

"Angular does not create the component if it is already present in the DOM. It reuses the component instance. This implies that the ngOnInit life cycle hook is not invoked when the user navigates to the component again." Based on this, I cannot understand why ngOnInit lifecyle method is invoked again if it contains the […]

Browser refresh with an angular app hosted on Firebase with a Firestore DB always goes to the Home Page. How do you stop that behavior?

I’ve created an Angular Application hosted on Firebase. For some reason, when I refresh the page (all platforms and browsers, including mobile), it does not land back on the page where the refresh occurred. It takes me to the home page. I’m assuming it’s redirecting or ‘rewriting’ and pointing back to the index.html. Has anybody […]

angular load modules based on url

I am trying to create an angular application, with two modules. One for the user part and one for the admin part. I would like to load the module only if needed. For example if the requested url is /my-account it would load the user module. But if it’s something that starts with /admin it […]

How to retain query parameters in url on page action, angular

using: Angular 13.1.1 problem: After navigating to a page using query parameters like so: https://localhost:7001/someaction?d=0d177bb4-474a-4a05-8d59-2e4da102abec the user should be able to manipulate the presented data on the page using various methods, supported by a service. Upon manipulation (opening a modal window for example) the url get’s re-written without the query parameters like so: https://localhost:7001/admin/someaction and […]

By mtholen
Categorized as angular, angular-router, angular-routing Tagged , ,

NGRX router-store: selectCurrentRoute selector undefined

I’m trying to use the selectCurrentRoute selector, but I only get undefined. export interface AppState { routerState: RouterReducerState<RouterStateUrl> } export const reducers: ActionReducerMap<AppState> = { routerState: routerReducer }; export const selectRouterState = createFeatureSelector<RouterReducerState<RouterStateUrl>>(‘routerState’); export const { selectCurrentRoute } = getSelectors(selectRouterState); export const getCurrentRoute = createSelector(selectRouterState, selectCurrentRoute); —— .select(routerFromSelector.getCurrentRoute) .subscribe((route) => console.log(route)); core.module.ts StoreModule.forRoot(reducers), StoreRouterConnectingModule.forRoot({ […]

By Max
Categorized as angular, angular-routing, ngrx, ngrx-store Tagged , , ,

Navigate to specific material tab using queryParams

I looked but didn’t find something that worked for me… I basically need a way to reach for a specific material tab inside a tab-group using queryParams on a button click. The already existing path, in this case, contains an ID for the element subjected to changes (that are found inside the material tabs), so […]

How to dynamically set page titles in the browser tab in Angular 8?

I have a scenario like there’s a list of employees in the developing application. When I click one employee name, it navigates to that employee’s details. Whenever i navigate to each employee’s details, my browser title should display information like “Employee Name: Employee Number". So that the title should change according to the employee. Suppose […]

By RoshiDil
Categorized as angular, angular-routing, typescript Tagged , ,
1 45

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