home
  • Blog
  • Home
  • Projects
    • Ember
    • EmberData
    • Ember CLI
2.18
  • Packages
    • @ember/application
    • @ember/array
    • @ember/component
    • @ember/controller
    • @ember/debug
    • @ember/engine
    • @ember/error
    • @ember/object
    • @ember/polyfills
    • @ember/routing
    • @ember/runloop
    • @ember/service
    • @ember/string
    • @ember/test
    • @ember/utils
    • ember-glimmer
    • jquery
  • Classes
    • Adapter
    • Application
    • ApplicationInstance
    • ApplicationInstance.BootOptions
    • ArrayProxy
    • Checkbox
    • Component
    • ComputedProperty
    • ContainerDebugAdapter
    • ContainerProxyMixin
    • Controller
    • CoreObject
    • DataAdapter
    • Ember.Debug
    • Ember.Logger
    • Ember.MutableEnumerable
    • Ember.Namespace
    • Ember.NativeArray
    • Ember.Templates.helpers
    • Ember.Test
    • Ember.Test.QUnitAdapter
    • EmberArray
    • EmberError
    • EmberObject
    • Engine
    • EngineInstance
    • Evented
    • GlobalsResolver
    • HashLocation
    • Helper
    • HistoryLocation
    • LinkComponent
    • Mixin
    • MutableArray
    • NoneLocation
    • ObjectProxy
    • Observable
    • PromiseProxyMixin
    • RSVP.EventTarget
    • RSVP.Promise
    • Route
    • Router
    • RouterService
    • Service
    • String
    • TextArea
    • TextField

Class RouterService public


Defined in: packages/ember-routing/lib/services/router.js:15
Module: ember

The Router service is the public API that provides component/view layer access to the router.


Methods

isActive (routeName, models, options) : Boolean public

Module: ember

Defined in packages/ember-routing/lib/services/router.js:196

routeName
String

the name of the route

models
...Object

the model(s) or identifier(s) to be used while transitioning to the route.

options
Object

optional hash with a queryParams property containing a mapping of query parameters

returns
Boolean

true if the provided routeName/models/queryParams are active

Determines whether a route is active.

replaceWith (routeNameOrUrl, models, options) : Transition public

Module: ember

Defined in packages/ember-routing/lib/services/router.js:158

routeNameOrUrl
String

the name of the route or a URL

models
...Object

the model(s) or identifier(s) to be used while transitioning to the route.

options
Object

optional hash with a queryParams property containing a mapping of query parameters

returns
Transition

the transition object associated with this attempted transition

Transition into another route while replacing the current URL, if possible. The route may be either a single route or route path:

See Route.replaceWith for more info.

transitionTo (routeNameOrUrl, models, options) : Transition public

Module: ember

Defined in packages/ember-routing/lib/services/router.js:128

routeNameOrUrl
String

the name of the route or a URL

models
...Object

the model(s) or identifier(s) to be used while transitioning to the route.

options
Object

optional hash with a queryParams property containing a mapping of query parameters

returns
Transition

the transition object associated with this attempted transition

Transition the application into another route. The route may be either a single route or route path:

See Route.transitionTo for more info.

urlFor (routeName, models, options) : String public

Module: ember

Defined in packages/ember-routing/lib/services/router.js:179

routeName
String

the name of the route

models
...Object

the model(s) or identifier(s) to be used while transitioning to the route.

options
Object

optional hash with a queryParams property containing a mapping of query parameters

returns
String

the string representing the generated URL

Generate a URL based on the supplied route name.

Properties

currentRouteName public

Module: ember

Defined in packages/ember-routing/lib/services/router.js:25

Name of the current route.

This property represent the logical name of the route, which is comma separated. For the following router:

app/router.js
Router.map(function() {
  this.route('about);
  this.route('blog', function () {
    this.route('post', { path: ':post_id' });
  });
});

It will return:

  • index when you visit /
  • about when you visit /about
  • blog.index when you visit /blog
  • blog.post when you visit /blog/some-post-id

currentURL public

Module: ember

Defined in packages/ember-routing/lib/services/router.js:54

Current URL for the application.

This property represent the URL path for this route.
For the following router:
app/router.js
Router.map(function() {
  this.route('about);
  this.route('blog', function () {
    this.route('post', { path: ':post_id' });
  });
});

It will return:

  • / when you visit /
  • /about when you visit /about
  • /blog/index when you visit /blog
  • /blog/post when you visit /blog/some-post-id

location public

Module: ember

Defined in packages/ember-routing/lib/services/router.js:82

The location property determines the type of URL's that your application will use. The following location types are currently available:

  • auto
  • hash
  • history
  • none

rootURL public

Module: ember

Defined in packages/ember-routing/lib/services/router.js:98

The rootURL property represents the URL of the root of the application, '/' by default. This prefix is assumed on all routes defined on this app.

IF you change the rootURL in your environment configuration like so:

config/environment.js
'use strict';

module.exports = function(environment) {
  let ENV = {
    modulePrefix: 'router-service',
    environment,
    rootURL: '/my-root',
  …
  }
]

This property will return /my-root.

On this page


Methods

  • isActive
  • replaceWith
  • transitionTo
  • urlFor

Properties

  • currentRouteName
  • currentURL
  • location
  • rootURL
Team Sponsors Security Legal Branding Community Guidelines
Twitter GitHub Discord Mastodon

If you want help you can contact us by email, open an issue, or get realtime help by joining the Ember Discord.

© Copyright 2025 - Tilde Inc.
Ember.js is free, open source and always will be.


Ember is generously supported by
blue Created with Sketch.