angular-router

Angular 8 scroll to a fragment, doesn't bring the fragment to the top of the page

妖精的绣舞 提交于 2020-01-05 08:34:08
问题 I have a link, by clicking on the link, I want to scroll to a fragment which is at the bottom of the page. When I click on the link, the fragment is working, but it doesn't bring it to the top of the page. I tried having the using div and section with an id to create the fragment. But, it doesn't bring the div or section to the top of the page. The code in my app routing module is: imports: [ RouterModule.forRoot(routes, { //useHash: true, scrollPositionRestoration: 'enabled',

Combine route and query parameters in Angular

不问归期 提交于 2020-01-04 09:17:25
问题 In Angular I have to process a route in the format /sections/{id}?filter={filter} i.e. I have a route parameter ( id ), and a query parameter ( filter ). Both parameters are optional, so all of these routes are valid and being listened to /sections/{id}?filter={filter} /sections?filter={filter} /sections/{id} /sections When handling a route I need to call a potentially expensive service, providing the parameters given. I can subscribe to both the params and queryParams of the route, but I

Angular Navigating to Secondary Route while Preserving Primary Route

☆樱花仙子☆ 提交于 2020-01-04 02:20:09
问题 I would like to navigate to a secondary route called modal without explicitly stating the primary route. I've tried this in the component class: onclick(){ this.router.navigate([{ outlets: { foo: 'modal' } }], { relativeTo: this.route }); } The above code seems to work. However, it navigates to /first(foo:modal) for a split second then it navigates to the root / . What am I doing wrong? It would be nice to do something like: <a href="#" routerLink="/*(foo:modal)">Open Modal</a> So that it

Navigation ID is not equal to the current router navigation id error

蹲街弑〆低调 提交于 2020-01-03 06:48:11
问题 I'm using @ngrx/router-store in my Angularv5 app and I recently started running into a an error: Navigation ID X is not equal to the current navigation id Y (where X and Y are integers). This problem happens consistently when I navigate to route A from a specific route B. Navigating to route A from any other route seems to work fine. The only other S.O. issue related to this which I've found, offers up the possibility that the issue could be caused by rapidly updating the navigation multiple

Hiding routes on url Angular 2+

穿精又带淫゛_ 提交于 2020-01-02 07:45:17
问题 So I am trying to hide my routes on the url, that means i want my app to show always the url as being in the root app, for example: "www.foo.com" instead of "www.foo.com/login" Its there any way to achieve this in angular 2? Thanks in advance for the help! 回答1: What you are looking for is Angulars skipLocationChange , this is what Angular refers to as "NavigationExtras". Here is the documentation: Angular docs on NavExtras // Navigate silently to /view this.router.navigate(['/view'], {

Angular 6 - Dynamic Routing with Prefix

点点圈 提交于 2020-01-02 04:35:17
问题 I am working on an Angular Universal Application. I want to create dynamic routes with custom prefix but I am unable find any helpful documentation related with my case. Any Help will be appreciated... Details: What I have is, I have 4 pages with 4 different dynamic URLs which are: Home Page ( http://example.com/ ) Category Page ( http://example.com/{category_name} ) Sub Category Page ( http://example.com/{category_name}/{sub_category_name} ) Product Page ( http://example.com/p{product_id}-

Angular2 - CustomResueStrategy when using combination of child and sibling routes gives error: Cannot read property '_outlets' of undefined at eval

被刻印的时光 ゝ 提交于 2019-12-25 08:57:18
问题 I have an Angular 2 app with several tabs for different features/components. One of the tabs is "Products" where I can see the list of products and search for products by typing name in a search field. So, I type a text in search text field and the matching records are filtered and displayed on the page. I can then click on the product to view its details and then come back to the main products tab. Now, I do not want to lose the search text and results on the products page. To solve this

Angular Nativescript can't navigate in lazy module

笑着哭i 提交于 2019-12-25 01:47:00
问题 Template I used : Nativescript-Tabs-Template When I try to navigate to sibling component (both are in one lazy module) with: showItem() { this.routerExtensions.navigate(["details/"]); } (also done this - not sure if this is ok ) : this.routerExtensions.navigate(["details", { outlets: { searchTab: ['details'] } }]); I get the error : Error: Cannot match any routes. URL Segment: 'details' *But when I navigate with nsRouterLink it works: * <Label text="this works" [nsRouterLink]="['/details']><

Navigate to last visited child route when entering parent route Angular 5

♀尐吖头ヾ 提交于 2019-12-24 08:50:07
问题 In my Angular 5 application I have my router configured as this: { path: 'system-variables', component: SystemVariablesComponent, children: [ { path: '', redirectTo: 'partners-variables', pathMatch: 'full' }, { path: 'partners-variables', component: PartnersVariablesComponent, children: [ { path: '', redirectTo: 'partners-branches', pathMatch: 'full' }, { path: 'partners-branches', component: PartnersBranchesComponent, children: [ { path: '', redirectTo: 'register-partners-branches',

how to make parent state active(i.e., add active class) when child is active

纵然是瞬间 提交于 2019-12-23 18:48:12
问题 I current have some routes <ul class=""> <li class=""> <a [routerLinkActive]="['active']" [routerLink]="['/user/traffic/graph']" class=""> Traffic </a> </li> </ul> Routes const trafficRoutes: Routes = [ { path: '', component: TrafficComponent, children: [ { path: '', redirectTo: 'graph' }, { path: 'graph', component: GraphComponent}, { path: 'alerts', component: AlertComponent} ] }, ]; The Router Link gets activated when I navigate to GraphComponent but when I navigate to AlertComponent it is