getOwner()
Returns the owner (DI container) associated with a framework object.
Syntax
getOwner(object): Owner | undefined Parameters
| Name | Type | Required | Description |
|---|---|---|---|
object | object | No | A framework object created by the container. |
Returns
Owner | undefined — The owning ApplicationInstance.
Examples
import Component from '@glimmer/component';
import { getOwner } from '@ember/owner';
export default class FeatureComponent extends Component {
get config() {
return getOwner(this).lookup('service:config');
}
}
Notes
Import getOwner from @ember/owner (the modern path). It only works on
objects the container created; plain POJOs return undefined. Use it for
dynamic lookups not expressible with @service.