* 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)
| 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. |
no test coverage detected