@@ -48,7 +48,7 @@ ember generate component blog-post
48
48
49
49
This will create a few different files:
50
50
51
- ```
51
+ ``` bash
52
52
installing component
53
53
create app/components/blog-post.js
54
54
create app/templates/components/blog-post.hbs
@@ -136,10 +136,9 @@ Here, we have two different kinds of dynamic values:
136
136
` {{this}} ` always refers to that instance, and allows you to access methods,
137
137
fields, and other properties on the class instance.
138
138
139
- We say that these values are _ bound_ to the template in those locations. It's
140
- important to note that arguments and properties can be used interchangeably, so
141
- we could for instance have used an argument for the ` sectionClass ` , and a
142
- class property for title or post content:
139
+ It's important to note that arguments and properties can be used
140
+ interchangeably, so we could for instance have used an argument for the
141
+ ` sectionClass ` , and a class property for title or post content:
143
142
144
143
``` handlebars {data-filename=app/templates/components/blog-post.hbs}
145
144
<h1>{{this.title}}</h1>
@@ -148,13 +147,11 @@ class property for title or post content:
148
147
</section>
149
148
```
150
149
151
- Both arguments and properties can be used in any valid binding location. For
152
- more details on where and how you can bind values, read through the
150
+ For more details on where and how you can invoke values, read through the
153
151
[ section on templating] ( ../../templates/handlebars-basics/ ) .
154
- The reason you would choose an argument or
155
- property is based on how you expect to use the component, and whether or not the
156
- value should be based on internal logic within the component, or values passed
157
- to the component where it is used.
152
+ The reason you would choose an argument or property is based on how you expect
153
+ to use the component, and whether or not the value should be based on internal
154
+ logic within the component, or values passed to the component where it is used.
158
155
159
156
You can also use template helpers, modifiers, and other components within your
160
157
component template:
@@ -207,7 +204,8 @@ And this will place the block - the text that is in between `<BlogPost>` and
207
204
``` html
208
205
<h1 >Fun Facts About Tomster</h1 >
209
206
<section class =" blog-post-section" >
210
- 1. He's a hamster! 2. But also a Tomster!
207
+ 1. He's a hamster!
208
+ 2. But also a Tomster!
211
209
</section >
212
210
```
213
211
@@ -255,8 +253,8 @@ or functional components, and their major difference is that they do not have an
255
253
_ instance_ or any instance state.
256
254
257
255
What this means in practice is that using properties in the template
258
- (` {{this.myProperty}} ` ) will result in an error. In a template-only component
259
- you can only use arguments (` {{@myArgument}} ` ).
256
+ (e.g. ` {{this.myProperty}} ` ) will result in an error. In a template-only component
257
+ you can only use arguments (e.g. ` {{@myArgument}} ` ).
260
258
261
259
Template-Only components are useful for components that don't need to have their
262
260
own state, such as components that focus on presentation and formatting of data.
@@ -343,7 +341,7 @@ known as _actions_, and are decorated with the `@action` decorator.
343
341
<section ...attributes class="{{this.sectionClass}}">
344
342
{{yield}}
345
343
346
- <button onclick={{ this.likePost}} class="like-button">
344
+ <button {{action this.likePost}} class="like-button">
347
345
Like!
348
346
</button>
349
347
</section>
@@ -368,16 +366,17 @@ export default class HelloButton extends Component {
368
366
```
369
367
370
368
Any method that you use in a template should be decorated with this decorator.
371
- It'll be covered in more detail in the section on [ Actions] ( ../actions ) .
369
+ It'll be covered in more detail in the section on [ Actions and
370
+ Events] ( ../actions-and-events ) .
372
371
373
372
#### Component Hooks and Properties
374
373
375
374
Components have the following class signature (this given as a TypeScript class
376
375
signature for clarity and brevity, if you don't know TypeScript, don't worry!
377
376
We'll explain what it all means in just a minute):
378
377
379
- ``` ts
380
- declare class GlimmerComponent {
378
+ ``` js
379
+ class GlimmerComponent {
381
380
args: object;
382
381
383
382
isDestroying: boolean;
0 commit comments