Skip to content

Commit 228f871

Browse files
committed
[Documentation] example using owner api
1 parent 91aba0e commit 228f871

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

addon/models/resource.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ const { computed, Logger } = Ember;
1717
define a prototype using `Resource.extend({ type: entity })`. Model prototypes
1818
are registered in the container as factories, they use the options:
1919
`{ instantiate: false, singleton: false }`. So, to create a model instance
20-
use the owner API or the container to `lookup` the factory, for exampe:
20+
use the owner API or the container to `lookup` the factory, for example:
2121
2222
```js
23-
let owner = Ember.getOwner(this) || this.container;
24-
owner.lookup('model:entity').create({ attributes: { key: value } });
23+
let owner = (typeof Ember.getOwner === 'function') ? Ember.getOwner(this) : this.container;
24+
let model = owner.lookup('model:entity').create({ attributes: { key: value } });
2525
```
2626
2727
See <http://jsonapi.org/format/#document-resource-objects>

0 commit comments

Comments
 (0)