Skip to content

feat(router) add possibilty to subscribe to current ActivatedRoute #9662

@choeller

Description

@choeller

I'm submitting a ... (check one with "x")

[ ] bug report
[x ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

Since #9390 is implemented we are now able to add a data-Object to the RouteConfig. This object is attached to the ActivatedRoute. As of now, I currently can't seem to find a way to globally subscribe to that ActivatedRoute to implement some generic functionallity like setting the browser title.

Expected/desired behavior

It would be super useful to be able to subscribe to the current ActivatedRoute or at least to be able to get this information ad-hoc from the router (via snapshot?!). Something like this would be quite nice:

    router.activatedRoute.subscribe((route: ActivatedRouteSnapshot) => {
      if (route.outlet == PRIMARY_OUTLET) {
        this.titleService.setTitle(route.data['title'] || "My default title");
      }
    })

What is the motivation / use case for changing the behavior?

Be able to solve generic routing issues by accessing information about the current route.

Please tell us about your environment:

  • Angular version: 2.0.0-rc.3
  • Browser: [all]
  • Language: [all ]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions