ember-engines-router-service

Provides the Router service for ember-engines.


Keywords
ember-addon
License
MIT
Install
npm install ember-engines-router-service@0.2.0

Documentation

ember-engines-router-service

npm version Build Status

This addon provides an API for authoring Router service in ember-engines.

Compatibility


  • Ember.js v3.12 or above
  • Ember CLI v2.13 or above
  • Node.js v10 or above

Installation


ember install ember-engines-router-service

Usage

Basically you have all RouterService API inside each engine such as transitionTo and isActive and also the same one using new "external routing" APIs such as transitionToExternal and isActiveExternal to link externalRoutes.


import Component from '@glimmer/component';
import { inject as service } from '@ember/service';
import { action } from "@ember/object";

export default class SomeComponent extends Component {
  @service router;

  @action
  transitionToHome() {
    this.router.transitionToExternal('other.route');
  }

  @action
  transitionToAdmin() {
    this.router.transitionTo('admin.route');
  }

  @action
  redirectToHome() {
    this.router.replaceWithExternal('other.route');
  }

  @action
  redirectToLogin() {
    this.router.replaceWith('login.route');
  }
}

For further documentation on this subject, view the Engine Linking RFC.

Contributing


See the Contributing guide for details.

License


This project is licensed under the MIT License.