MCPcopy
hub / github.com/angular-ui/ui-router / otherwise

Method otherwise

src/urlRouterProvider.ts:116–127  ·  view source on GitHub ↗

* Defines the path or behavior to use when no url can be matched. * * #### Example: * ```js * var app = angular.module('app', ['ui.router.router']); * * app.config(function ($urlRouterProvider) { * // if the path doesn't match any of the urls you configured * // otherwise

(rule: string | RawNg1RuleFunction)

Source from the content-addressed store, hash-verified

114 * @return {object} `$urlRouterProvider` - `$urlRouterProvider` instance
115 */
116 otherwise(rule: string | RawNg1RuleFunction): UrlRouterProvider {
117 const urlRules = this.router.urlService.rules;
118 if (isString(rule)) {
119 urlRules.otherwise(rule);
120 } else if (isFunction(rule)) {
121 urlRules.otherwise(() => rule(services.$injector, this.router.locationService));
122 } else {
123 throw new Error("'rule' must be a string or function");
124 }
125
126 return this;
127 }
128
129 /**
130 * Registers a handler for a given url matching.

Callers 2

stateSpec.tsFile · 0.80
urlRouterSpec.tsFile · 0.80

Calls 2

isStringFunction · 0.50
isFunctionFunction · 0.50

Tested by

no test coverage detected