GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Docs
  • Tutorials
  • Playground
  • Reference
  • code
  • Router
  • Routing and Navigation guide
  • ActivatedRoute
  • Params
  • QueryParamsHandling

This view

  • Original page
  • New address

GeezerVison is showing next.angular.dev — UrlCreationOptions • Angular

API

    
      interface UrlCreationOptions {}
    
    

Specifies a root URI to use for relative navigation.

For example, consider the following route configuration where the parent route has two children.

[{
  path: 'parent',
  component: ParentComponent,
  children: [{
    path: 'list',
    component: ListComponent
  },{
    path: 'child',
    component: ChildComponent
  }]
}]

The following go() function navigates to the list route by interpreting the destination URI as relative to the activated child route

@Component({...})
class ChildComponent {
  constructor(private router: Router, private route: ActivatedRoute) {}

  go() {
    router.navigate(['../list'], { relativeTo: this.route });
  }
}

A value of null or undefined indicates that the navigation commands should be applied relative to the root.

Sets query parameters to the URL.

// Navigate to /results?page=1
router.navigate(['/results'], { queryParams: { page: 1 } });

Sets the hash fragment for the URL.

// Navigate to /results#top
router.navigate(['/results'], { fragment: 'top' });

How to handle query parameters in the router link for the next navigation. One of:

  • preserve : Preserve current parameters.
  • merge : Merge new with current parameters.

The "preserve" option discards any new query params:

// from /view1?page=1 to/view2?page=1
router.navigate(['/view2'], { queryParams: { page: 2 },  queryParamsHandling: "preserve"
});

The "merge" option appends new query params to the params from the current URL:

// from /view1?page=1 to/view2?page=1&otherKey=2
router.navigate(['/view2'], { queryParams: { otherKey: 2 },  queryParamsHandling: "merge"
});

In case of a key collision between current parameters and those in the queryParams object, the new value is used.

When true, preserves the URL fragment for the next navigation

// Preserve fragment from /results#top to /view#top
router.navigate(['/view'], { preserveFragment: true });
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.