2

I want to define any in url whit angular ui-router

in angular self router we can define a route like this:

$routeProvider.when('/:params*', {
    template: 'test',
  })

and when call this url

/a/b/c

it's work

how can do same in angular ui-router

1 Answer 1

6

For eager matching of URL parameters, use:

$stateProvider
.state('all', {
    url: "/*params",
    template: "test"
});

//OR

$stateProvider
.state('all', {
    url: "/{params:.*}",
    template: "test"
});

From the Docs:

URL Regex Parameters

Examples:

  • '/files/{path:.*}' - Matches any URL starting with '/files/' and captures the rest of the path into the parameter 'path'.
  • '/files/*path' - Ditto. Special syntax for catch all.

— UI-Router Wiki URL-Routing regex parameters

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.