UrlService provides an API for managing URLs in UI-Router. It combines URL configuration, URL rules management, and low-level URL read/write operations.
Overview
TheUrlService is the primary API for URL management. Access it via router.urlService.
Properties
rules
config
Methods
parts()
Gets the current URL parts.path, search, and hash parts.
Example:
sync()
Activates the best rule for the current URL.listen()
Starts or stops listening for URL changes.enabled-trueorfalseto start or stop listening to URL changes
deferIntercept()
Disables monitoring of the URL.defer- Indicates whether to defer location change interception (defaults totrue)
match()
Matches a URL against all registered rules.url- AUrlPartsobject containingpath,search, andhash
undefined if no rule matched.
url()
Gets or updates the URL.newurl- The new URL value (optional)replace- When true, replaces the current history entry instead of appending (optional)state- The history’s state object (optional)
path()
Gets the path part of the current URL.search()
Gets the search part of the current URL as an object.hash()
Gets the hash part of the current URL.onChange()
Registers a low-level URL change handler.callback- A function called when the URL is changing