Skip to content

AnastasiiaPlutalova/ember-engines-router-service

 
 

Repository files navigation

ember-engines-router-service

npm version Build Status

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

Compatibility


  • Ember.js v3.12 or above
  • Ember CLI v3.24 or above
  • Node.js v12 or above

Installation


ember install ember-engines-router-service

Usage

Basically you have the full RouterService API inside each engine. That means you can use APIs such as transitionTo and isActive, plus the new "external routing" APIs such as transitionToExternal and isActiveExternal which help link externalRoutes together.


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.

About

Provides the Router service for ember-engines

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 79.6%
  • Handlebars 15.2%
  • HTML 5.1%
  • CSS 0.1%