used to create UrlRule objects for common cases
Disables monitoring of the URL.
Disables monitoring of the URL.
Call this method before UI-Router has bootstrapped. It will stop UI-Router from performing the initial url sync.
This can be useful to perform some asynchronous initialization before the router starts. Once the initialization is complete, call listen to tell UI-Router to start watching and synchronizing the URL.
// Prevent $urlRouter from automatically intercepting URL changes when it starts;
urlService.deferIntercept();
$http.get('/states.json').then(function(resp) {
resp.data.forEach(state => $stateRegistry.register(state));
urlService.listen();
urlService.sync();
});
Builds and returns a URL with interpolated parameters
Builds and returns a URL with interpolated parameters
matcher = $umf.compile("/about/:person");
params = { person: "bob" };
$bob = $urlRouter.href(matcher, params);
// $bob == "/about/bob";
The UrlMatcher object which is used as the template of the URL to generate.
An object of parameter values to fill the matcher's required parameters.
Options object. The options are:
absolute
- {boolean=false}, If true will generate an absolute url, e.g. "http://www.example.com/fullurl".Returns the fully compiled URL, or null
if params
fail validation against urlMatcher
Starts or stops listening for URL changes
Starts or stops listening for URL changes
Call this sometime after calling deferIntercept to start monitoring the url. This causes UrlRouter to start listening for changes to the URL, if it wasn't already listening.
If called with false
, will stop listening. Call listen() again to start listening
urlService.deferIntercept();
$http.get('/states.json').then(function(resp) {
resp.data.forEach(state => $stateRegistry.register(state));
// Start responding to URL changes
urlService.listen();
urlService.sync();
});
Given a URL, check all rules and return the best MatchResult
Given a URL, check all rules and return the best MatchResult
Defines the path or behavior to use when no url can be matched.
Defines the path or behavior to use when no url can be matched.
When no other url rule matches, redirect to /index
.otherwise('/index');
When no other url rule matches, redirect to /index
.otherwise(() => '/index');
When no other url rule matches, go to home
state
.otherwise((url, router) => {
router.stateService.go('home');
return;
}
Internal API.
Internal API.
Pushes a new location to the browser history.
Manually adds a URL Rule.
Manually adds a URL Rule.
Usually, a url rule is added using StateDeclaration.url or when. This api can be used directly for more control (to register a BaseUrlRule, for example). Rules can be created using UrlRouter.urlRuleFactory, or create manually as simple objects.
A rule should have a match
function which returns truthy if the rule matched.
It should also have a handler
function which is invoked if the rule is the best match.
a function that deregisters the rule
Gets all registered rules
Gets all registered rules
an array of all the registered rules
Checks the URL for a matching UrlRule
Checks the URL for a matching UrlRule
Checks the current URL for a matching url rule, then invokes that rule's handler. This method is called internally any time the URL has changed.
This effectively activates the state which matches the current URL.
urlService.deferIntercept();
$http.get('/states.json').then(function(resp) {
resp.data.forEach(state => $stateRegistry.register(state));
urlService.listen();
// Find the matching URL and invoke the handler.
urlService.sync();
});
Internal API.
Internal API.
Generated using TypeDoc
Updates URL and responds to URL changes
This class updates the URL when the state changes. It also responds to changes in the URL.