UrlMatcher class matches URLs against patterns and extracts named parameters from the path or search portions of the URL.
Overview
? and a list of search (query) parameters. Multiple search parameter names are separated by &.
Pattern Syntax
Path Parameters
Path parameters are defined using:- Curly brace placeholders:
/somepath/{param} - Colon placeholders:
/somePath/:param
Parameter RegExp
A parameter RegExp may be defined after a colon:Custom Parameter Types
Custom parameter types may be specified after a colon:Catch-All Parameters
Catch-all parameters are defined using an asterisk:Examples
Properties
pattern
Methods
exec()
Tests the specified URL against this matcher.path- The URL path to match (e.g.,$location.path())search- URL search parameters (e.g.,$location.search())hash- URL hash (e.g.,$location.hash())options- Options object
null if the path does not match.
Example:
format()
Creates a URL from a set of parameter values.values- The parameter values to substitute into the pattern
null if validation failed.
Example:
validates()
Validates parameter values against this UrlMatcher.params- The parameter object to validate
true if the params validate correctly.
append()
Creates a new concatenated UrlMatcher.url- AUrlMatcherinstance to append as a child
UrlMatcher.
Builds a new UrlMatcher by appending another UrlMatcher to this one.
parameters()
Returns all path and search parameters.opts- Options object (e.g.,{ inherit: false })
Param objects. Must be treated as read-only.
parameter()
Returns a single parameter by id.id- The parameter idopts- Options object (e.g.,{ inherit: false })
Param object or null.
toString()
Returns the input pattern string.Static Methods
compare()
Compares two UrlMatchers for specificity.a- First UrlMatcherb- Second UrlMatcher
- Negative number if
ais more specific - Positive number if
bis more specific 0if equally specific