Service Injection into routes fails (Ember 2.4.1)


#1

I try to inject a custom service into routes

-services/custom-service.js

import Ember from 'ember';

export default Ember.Service.extend({
    isSuccess: false
});

-routes/myroute.js

export default Ember.Route.extend({
  srv: Ember.inject.service('custom-service')
});

It doesn’t work and returns the fallowing error:

Error: Attempting to inject an unknown injection: service:custom-service

Another way from official guide also doesn’t work: -initializers/custom-service.js

export function initialize(application) {
  application.inject('route', 'srv', 'service:custom-service');
}

export default {
  name: 'custom-service',
  initialize: initialize
};

It always returns

Error: Attempting to inject an unknown injection: service:custom-service

Is it possible to inject service into a route in Ember v2.4.1 ? With components it works fine.


#2

Injecting a service on to a route should work fine. Can you through together a sample app with the issue and I’ll try and help debug this.


#3

I fixed this by upgrading ember-cli to the latest release. Now it works )