UrlConfig API customizes the URL behavior and retrieves URL configuration metadata.
Overview
Access theUrlConfig API via router.urlService.config.
Configuration Methods
caseInsensitive()
Defines whether URL matching should be case sensitive.value-falseto match URLs in a case-sensitive manner;truefor case-insensitive (optional)
caseInsensitive.
Example:
strictMode()
Defines whether URLs should match trailing slashes.value-falseto match trailing slashes in URLs;truefor strict mode (optional)
strictMode.
Default: true (trailing slashes must match exactly)
Example:
defaultSquashPolicy()
Sets the default behavior when generating or matching URLs with default parameter values.value- The squash policy:falseor'nosquash': Don’t squash default parameter values from the URLtrueor'slash': Squash default values and remove one slash if surrounded by slashes- Any other string (e.g.,
'~'): Replace the default value with this string
defaultSquashPolicy.
Example:
type()
Creates and registers a custom parameter type.name- The type namedefinition- The type definition (optional)definitionFn- A function that returns a type definition to be merged withdefinition(optional)
- If only
nameis specified: the registeredParamTypeorundefined - If
definitionis specified:this(for chaining)
Information Methods
These methods return information about the current location configuration:baseHref()
Gets the base HREF.http://localhost/approot/)
host()
Gets the host.localhost)
port()
Gets the port.80)
protocol()
Gets the protocol.http)
html5Mode()
Returns true when running in pushstate mode.true when running in HTML5 mode (pushstate mode)
hashPrefix()
Gets or sets the hash prefix.newprefix- The new hash prefix (optional)
! for hashbang URLs)
Example: