Skip to content

Latest commit

 

History

History
26 lines (21 loc) · 586 Bytes

avoid-using-needs-in-controllers.md

File metadata and controls

26 lines (21 loc) · 586 Bytes

Don't use needs to load other controllers

Rule name: avoid-using-needs-in-controllers

Avoid using needs to load other controllers. Inject the required controller instead. needs was deprecated in ember 1.x and removed in 2.0.

// Bad
export default Controller.extend({
  needs: ['comments'],
  newComments: alias('controllers.comments.newest')
});
// Good
import Controller, {
  inject as controller
} from '@ember/controller';

export default Component.extend({
  comments: controller(),
  newComments: alias('comments.newest')
});