# Question on autofocus for form field

**URL:** <https://discuss.emberjs.com/t/question-on-autofocus-for-form-field/14530>\
**Category:** Uncategorized\
**Created:** [April 13, 2018, 7:51pm UTC](https://discuss.emberjs.com/t/question-on-autofocus-for-form-field/14530 "2018-04-13T19:51:58Z")\
**Posts on this page:** 1\
**Showing post:** 11

<div class="post-metadata">

**Author:** ![mattmcmanus](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/mattmcmanus/32/13776_2.png) [@mattmcmanus](https://discuss.emberjs.com/u/mattmcmanus)\
**Post date:** [April 19, 2018, 9:04pm UTC](https://discuss.emberjs.com/t/question-on-autofocus-for-form-field/14530/11 "2018-04-19T21:04:20Z")

</div>

Think of components as isolated scopes. They won’t know of anything unless you tell them about it. There are two ways to give data to components. 1. Attributes and 2. dependency injection. You’re running into issues with both here.

### Component attributes

You’re component doesn’t know about `model` internally because you need to pass it in. Invoking the component with the model attribute will make `model` available in your component

```
{{create-form model=model}}

```

### Dependency injection

For certain things, it’s easier to inject them into a component rather than pass them in. These “things” are known as services in ember. In javascript parlance, they are singletons. This means there is a single one that the framework keeps around for you (rather then destroying and recreating it each time you use it, like components). There are many reasons this is really nice. In your example, the `store` is a service that you will need to inject in order to use within the component.

```js
import Component from '@ember/component';
import { inject as service } from '@ember/service'; // Import the service injector

export default Component.extend({
  store: service(), // Tell the component what service you want to inject. 
  storeService: service('store') // The above is a shorthand. You could also do this
  ....
  this.get('store').createRecord.....
});

```

Note the usage `this.get()`. For now, use `.get` whenever you access properties.

Anyway, I hope that makes sense.

---

_[View the full topic](https://discuss.emberjs.com/t/question-on-autofocus-for-form-field/14530)._
