Function
inject (name) Ember.InjectedProperty public
| Module: | @ember/controller |
|---|
Defined in packages/ember-runtime/lib/controllers/controller.js:29
Available since v1.10.0
import { inject } from '@ember/controller'; - name
- String
- (optional) name of the controller to inject, defaults to the property's name
- returns
- Ember.InjectedProperty
- injection descriptor instance
Creates a property that lazily looks up another controller in the container. Can only be used when defining another controller.
Example:
app/controllers/post.jsimport Controller, {
inject as controller
} from '@ember/controller';
export default Controller.extend({
posts: controller()
}); This example will create a posts property on the post controller that looks up the posts controller in the container, making it easy to reference other controllers.
© 2020 Yehuda Katz, Tom Dale and Ember.js contributors
Licensed under the MIT License.
https://api.emberjs.com/ember/2.18/functions/@ember%2Fcontroller/inject