« All deprecation guides
Deprecation Guide for
Importing
Deprecation Guide for
Importing inject
from @ember/service
until: 7.0.0
id: importing-inject-from-ember-service
Importing inject
from @ember/service
is deprecated. Please import service
instead.
Example:
my-route.js
import { Route } from '@ember/routing/route';
import { inject as service } from '@ember/service';
import { service } from '@ember/service';
export default class MyRoute extends Route {
@service store;
}
You can use the ember-codemod-remove-inject-as-service codemod, to fix all violations.
If you're working on a library that needs to support ember-source prior to 4.1, you can support both styles of service
via:
import * as emberService from '@ember/service';
const service = emberService.service ?? emberService.inject;