Skip to content

A reverse function that generates URI string from state name and params? #128

Closed
@liokm

Description

@liokm

It would be nice to have a reverse function in $state to map state name and params to corresponding URI. For example:

$stateProvider
  .state('foo.bar', {
    url: '/{fooId}/{barId}'
  });

then
$state.reverse('foo.bar', {fooId:1, barId:2}) generates URI string: '/1/2' (or '#/1/2', depends on html5mode)

Currently, this could be done by using $state.$current.url.format for the current state or ancestor states, but not for the other such as sibling states. Comparing with concatenating strings, this way feels neat and better managed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions