Skip to content

Commit f86e8ef

Browse files
docs($urlMatcherFactory): Add example for .type()
1 parent c18825f commit f86e8ef

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/urlMatcherFactory.js

+12-3
Original file line numberDiff line numberDiff line change
@@ -335,9 +335,18 @@ UrlMatcher.prototype.format = function (values) {
335335
* See {@link ui.router.util.$urlMatcherFactory#methods_type `$urlMatcherFactory#type()`} for more
336336
* information on registering custom types.
337337
*
338-
* @param {Object} config A configuration object hash that includes any method in `Type`'s public
339-
* interface, and/or `pattern`, which should contain a custom regular expression used to match
340-
* string parameters originating from a URL.
338+
* @param {Object} config A configuration object which contains the custom type definition. The object's
339+
* properties will override the default methods and/or pattern in `Type`'s public interface.
340+
* @example
341+
* <pre>
342+
* {
343+
* decode: function(val) { return parseInt(val, 10); },
344+
* encode: function(val) { return val && val.toString(); },
345+
* equals: function(a, b) { return this.is(a) && a === b; },
346+
* is: function(val) { return angular.isNumber(val) isFinite(val) && val % 1 === 0; },
347+
* pattern: /\d+/
348+
* }
349+
* </pre>
341350
*
342351
* @property {RegExp} pattern The regular expression pattern used to match values of this type when
343352
* coming from a substring of a URL.

0 commit comments

Comments
 (0)