MCPcopy Create free account
hub / github.com/angular-ui/ui-router / rule

Method rule

src/urlRouterProvider.ts:80–88  ·  view source on GitHub ↗

* Registers a url handler function. * * Registers a low level url handler (a `rule`). * A rule detects specific URL patterns and returns a redirect, or performs some action. * * If a rule returns a string, the URL is replaced with the string, and all rules are fired again. * * #

(ruleFn: RawNg1RuleFunction)

Source from the content-addressed store, hash-verified

78 * @return [[UrlRouterProvider]] (`this`)
79 */
80 rule(ruleFn: RawNg1RuleFunction): UrlRouterProvider {
81 if (!isFunction(ruleFn)) throw new Error("'rule' must be a function");
82
83 const match = () => ruleFn(services.$injector, this.router.locationService);
84
85 const rule = new BaseUrlRule(match, identity);
86 this.router.urlService.rules.rule(rule);
87 return this;
88 }
89
90 /**
91 * Defines the path or behavior to use when no url can be matched.

Callers 1

urlRouterSpec.tsFile · 0.80

Calls 1

isFunctionFunction · 0.50

Tested by

no test coverage detected