PUBLIC
Extends: Ember.Object
Uses: Ember.Evented
Defined in: packages/ember-routing/lib/system/router.js:51
Module: ember-routing
The Ember.Router class manages the application state and URLs. Refer to the routing guide for documentation.
Deserializes the value of a query parameter based on a default type
Object
String
Voidprivate
Deserializes the given query params according to their QP meta information.
Array
Object
Void Voidprivate
Maps all query param keys to their fully scoped property name of the form controllerName:propName.
String
Array
Object
Void Objectprivate
Returns the meta information for the query params of a given route. This will be overriden to allow support for lazy routes.
HandlerInfo
Object Voidprivate
Hydrates (adds/restores) any query params that have pre-existing values into the given queryParams hash. This is what allows query params to be "sticky" and restore their last known values for their scope.
TransitionState
Object
Void Voidprivate
Prepares the query params for a URL or Transition. Restores any undefined QP keys/values, serializes all values, and then prunes any default values.
String
Array
Object
Void Voidprivate
Removes (prunes) any query params with default values from the given QP object. Default values are determined from the QP meta information per key.
Array
Object
Void Objectprivate
Returns a merged query params meta object for a given set of handlerInfos. Useful for knowing what query params are available for a given route hierarchy.
Array
Object Serializes the value of a query parameter based on a type
Object
String
Voidprivate
Serializes the given query params according to their QP meta information.
Arrray
Object
Void Handles updating the paths and notifying any listeners of the URL change.
Triggers the router level didTransition hook.
For example, to notify google analytics when the route changes, you could use this hook. (Note: requires also including GA scripts, etc.)
let Router = Ember.Router.extend({
location: config.locationType,
didTransition: function() {
this._super(...arguments);
return ga('send', 'pageview', {
'page': this.get('url'),
'title': this.get('url')
});
}
});
Booleanprivate
Does this router instance have the given route.
Boolean Booleanprivate
Determines if the supplied route is currently active.
Boolean Booleanprivate
An alternative form of isActive that doesn't require manual concatenation of the arguments into a single array.
Boolean The Router.map function allows you to define mappings from URLs to routes in your application. These mappings are defined within the supplied callback function using this.route.
The first parameter is the name of the route which is used by default as the path name as well.
The second parameter is the optional options hash. Available options are:
path: allows you to provide your own path as well as mark dynamic segments.resetNamespace: false by default; when nesting routes, ember will combine the route names to form the fully-qualified route name, which is used with {{link-to}} or manually transitioning to routes. Setting resetNamespace: true will cause the route not to inherit from its parent route's names. This is handy for preventing extremely long route names. Keep in mind that the actual URL path behavior is still retained.The third parameter is a function, which can be used to nest routes. Nested routes, by default, will have the parent route tree's route name and path prepended to it's own.
App.Router.map(function(){
this.route('post', { path: '/post/:post_id' }, function() {
this.route('edit');
this.route('comments', { resetNamespace: true }, function() {
this.route('new');
});
});
});
For more detailed documentation and examples please see the guides.
Resets the state of the router by clearing the current route handlers and deactivating them.
Initializes the current router instance and sets up the change handling event listeners used by the instances location implementation.
A property named initialURL will be used to determine the initial URL. If no value is found / will be used.
Transitionpublic
Transition the application into another route. The route may be either a single route or route path:
See Route.transitionTo for more info.
String
...Object
[Object]
Transition Stringprivate
Represents the current URL.
String Handles notifying any listeners of an impending URL change.
Triggers the router level willTransition hook.
The location property determines the type of URL's that your application will use.
The following location types are currently available:
history - use the browser's history API to make the URLs look just like any standard URLhash - use # to separate the server part of the URL from the Ember part: /blog/#/posts/new
none - do not store the Ember URL in the actual browser URL (mainly used for testing)auto - use the best option based on browser capabilites: history if possible, then hash if possible, otherwise none
Note: If using ember-cli, this value is defaulted to auto by the locationType setting of /config/environment.js
Default: 'hash'
Represents the URL of the root of the application, often '/'. This prefix is assumed on all routes defined on this router.
Default: '/'
© 2017 Yehuda Katz, Tom Dale and Ember.js contributors
Licensed under the MIT License.
http://emberjs.com/api/classes/Ember.Router.html