54
54
_Angular modules_ are a big deal.
55
55
This page introduces modules; the [Angular modules](ngmodule.html) page covers them in depth.
56
56
57
- <br clear = " all " ><br >
57
+ <br class = " l-clear-both " ><br >
58
58
:marked
59
59
Every Angular app has at least one module, the _root module_, conventionally named `AppModule`.
60
60
@@ -130,7 +130,7 @@ figure
130
130
Each Angular library name begins with the `!{_at_angular}` prefix.
131
131
132
132
You install them with the **npm** package manager and import parts of them with JavaScript `import` statements.
133
- <br clear = " all " ><br >
133
+ <br class = " l-clear-both " ><br >
134
134
:marked
135
135
For example, import Angular's `Component` decorator from the `@angular/core` library like this:
136
136
+ makeExample('app/app.component.ts' , 'import' , '' )( format ='.' )
@@ -214,7 +214,7 @@ figure
214
214
:marked
215
215
Notice how `<hero-detail>` rests comfortably among native HTML elements. Custom components mix seamlessly with native HTML in the same layouts.
216
216
217
- <br clear = " all " >
217
+ <br class = " l-clear-both " >
218
218
219
219
.l-hr
220
220
@@ -226,7 +226,7 @@ figure
226
226
227
227
:marked
228
228
<p style =" padding-top :10px " >Metadata tells Angular how to process a class.</p >
229
- <br clear = " all " >
229
+ <br class = " l-clear-both " >
230
230
:marked
231
231
[Looking back at the code](#component-code) for `HeroListComponent`, you can see that it's just a class.
232
232
There is no evidence of a framework, no "Angular" in it at all.
@@ -275,7 +275,7 @@ figure
275
275
276
276
Apply other metadata !{_decorator}s in a similar fashion to guide Angular behavior.
277
277
`@Injectable`, `@Input`, and `@Output` are a few of the more popular !{_decorator}s.
278
- <br clear = " all " >
278
+ <br class = " l-clear-both " >
279
279
:marked
280
280
The architectural takeaway is that you must add metadata to your code
281
281
so that Angular knows what to do.
@@ -296,7 +296,7 @@ figure
296
296
Add binding markup to the template HTML to tell Angular how to connect both sides.
297
297
298
298
As the diagram shows, there are four forms of data binding syntax. Each form has a direction — to the DOM, from the DOM, or in both directions.
299
- <br clear = " all " >
299
+ <br class = " l-clear-both " >
300
300
:marked
301
301
The `HeroListComponent` [example](#templates) template has three forms:
302
302
@@ -330,12 +330,12 @@ figure
330
330
:marked
331
331
Data binding plays an important role in communication
332
332
between a template and its component.
333
- <br clear = " all " >
333
+ <br class = " l-clear-both " >
334
334
figure
335
335
img( src ="/resources/images/devguide/architecture/parent-child-binding.png" alt ="Parent/Child binding" style ="float:left; width:300px; margin-left:-40px;margin-right:10px" )
336
336
:marked
337
337
Data binding is also important for communication between parent and child components.
338
- <br clear = " all " >
338
+ <br class = " l-clear-both " >
339
339
340
340
.l-hr
341
341
@@ -350,7 +350,7 @@ figure
350
350
351
351
A directive is a class with directive metadata. In !{_Lang}, apply the `@Directive` !{_decorator}
352
352
to attach metadata to the class.
353
- <br clear = " all " >
353
+ <br class = " l-clear-both " >
354
354
:marked
355
355
A component is a *directive-with-a-template*;
356
356
a `@Component` !{_decorator} is actually a `@Directive` !{_decorator} extended with template-oriented features.
@@ -410,7 +410,7 @@ figure
410
410
411
411
Almost anything can be a service.
412
412
A service is typically a class with a narrow, well-defined purpose. It should do something specific and do it well.
413
- <br clear = " all " >
413
+ <br class = " l-clear-both " >
414
414
:marked
415
415
Examples include:
416
416
* logging service
@@ -463,7 +463,7 @@ figure
463
463
_Dependency injection_ is a way to supply a new instance of a class
464
464
with the fully-formed dependencies it requires. Most dependencies are services.
465
465
Angular uses dependency injection to provide new components with the services they need.
466
- <br clear = " all " >
466
+ <br class = " l-clear-both " >
467
467
:marked
468
468
Angular can tell which services a component needs by looking at the types of its constructor parameters.
469
469
For example, the constructor of your `HeroListComponent` needs a `HeroService`:
0 commit comments