# בעלות על אובייקט Ember (getOwner, הזרקות שירותים, וכו׳)

**URL:** https://meta.discourse.org/t/ember-object-ownership-getowner-service-injections-etc/292080
**Category:** Developer Guides
**Tags:** code
**Created:** [19 בינואר,‏ 2024,‏ 1:28pm UTC](https://meta.discourse.org/t/ember-object-ownership-getowner-service-injections-etc/292080 "2024-01-19T13:28:42Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Discourse](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/discourse/32/148734_2.png) [@Discourse](https://meta.discourse.org/u/Discourse)
#### Post date: [19 בינואר,‏ 2024,‏ 1:28pm UTC](https://meta.discourse.org/t/ember-object-ownership-getowner-service-injections-etc/292080/1 "2024-01-19T13:28:42Z")

</div>

> ⚠ Importing getOwner from `discourse-common/lib/get-owner` is deprecated.

To access e.g. services there a couple of methods at your disposal.

- In components/controllers/routes you should use service injections

- In cases where a service can be unavailable (i.e. it comes from an optional plugin) there’s a `optionalService` injection

- In API initializers you have the access to `api.container`

- And for a direct replacement of an existing code you can use

- …or if you still need the fallback shim (in a non-component/controller/route/widget context) use

* * *

This document is version controlled - suggest changes [on github](https://github.com/discourse/discourse/blob/main/docs/developer-guides/docs/03-code-internals/07-ember-object-ownership.md).
