More revisions.
This commit is contained in:
parent
890be79ded
commit
9eaf05b0f2
|
@ -43,7 +43,7 @@
|
||||||
code
|
code
|
||||||
| import {Component, Template, bootstrap} from 'angular2/angular2';
|
| import {Component, Template, bootstrap} from 'angular2/angular2';
|
||||||
p
|
p
|
||||||
| The above import statement will import the three basic pieces needed to create an Angular app. The import statement loads the modules dynamically at runtime.
|
| The above import statement will import the three modules from Angular. These modules load at runtime.
|
||||||
|
|
||||||
// STEP 3 - Create a component ##########################
|
// STEP 3 - Create a component ##########################
|
||||||
.content-block.content-number.clearfix
|
.content-block.content-number.clearfix
|
||||||
|
@ -54,12 +54,12 @@
|
||||||
|
|
||||||
h3#section-angular-create-account Create a component
|
h3#section-angular-create-account Create a component
|
||||||
p
|
p
|
||||||
| Angular allows you to create custom HTML elements through components. Components are used to structure and represent the UI. This quickstart demonstrates the process of creating a <code>Component</code> with the HTML tag of <code>app</code>.
|
| Components are custom HTML elements. Angular uses components to empower HTML. Components structure and represent the UI. This quickstart demonstrates the process of creating a component. This component will have the tag of app.
|
||||||
|
|
||||||
pre
|
pre
|
||||||
code <app></app>
|
code <app></app>
|
||||||
|
|
||||||
p A <code>Component</code> is made up of two parts; the annotation section and the component controller.
|
p A component consists of two parts; the annotation section and the component controller.
|
||||||
|
|
||||||
pre
|
pre
|
||||||
code
|
code
|
||||||
|
@ -85,13 +85,11 @@
|
||||||
h4 Component Annotations
|
h4 Component Annotations
|
||||||
.c6
|
.c6
|
||||||
p
|
p
|
||||||
| A component annotation provides meta-data about the <code>component</code>. An annotation can always identified by its <code>@</code> sign.
|
| A component annotation provides meta-data about the <code>component</code>. An annotation can always identified by its at-sign — <code>@</code>.
|
||||||
|
p
|
||||||
p
|
| The <code>@Component</code> annotation defines the HTML tag for the component. The selector property specifies the tag. The <code>selector</code> property is a CSS selector.
|
||||||
| The <code>@Component</code> annotation tells Angular what the HTML tag will be for your component. The tag is specified by using the <code>selector</code> property. The <code>selector</code> property is just a CSS selector.
|
p
|
||||||
|
| The <code>@Template</code> annotation defines the template to apply to the component. This component uses an inline template, but external templates are available as well. To use an external template specify a <code>url</code> property and give it the path to the html file.
|
||||||
p
|
|
||||||
| The <code>@Template</code> annotation tells Angular what template to apply to your component. This component uses an inline template, but external templates are available as well. To use an external template specify a <code>url</code> property and give it the path to the html file.
|
|
||||||
pre
|
pre
|
||||||
code
|
code
|
||||||
| @Component({
|
| @Component({
|
||||||
|
@ -103,14 +101,14 @@
|
||||||
| `
|
| `
|
||||||
| })
|
| })
|
||||||
p
|
p
|
||||||
| The component created above will have a HTML tag of <code><app></app></code> and a template of <code><h1>Hello {{ name }}</h1></code>.
|
| The component created above has a HTML tag of <code><app></app></code> and a template of <code><h1>Hello {{ name }}</h1></code>.
|
||||||
.clear
|
.clear
|
||||||
|
|
||||||
section.docs-sub-section
|
section.docs-sub-section
|
||||||
h4 Component Controller
|
h4 Component Controller
|
||||||
.c6
|
.c6
|
||||||
p
|
p
|
||||||
| The component controller is defined using the ES6 <code>class</code> syntax. This <code>class</code> is the backing of the component's template.
|
| The component controller is the backing of the component's template. A component controller uses ES6 <code>class</code> syntax.
|
||||||
pre
|
pre
|
||||||
code
|
code
|
||||||
| class AppComponent {
|
| class AppComponent {
|
||||||
|
@ -121,7 +119,7 @@
|
||||||
p
|
p
|
||||||
| Templates read from their component controllers. Templates have access to any properties or functions placed on the component controller.
|
| Templates read from their component controllers. Templates have access to any properties or functions placed on the component controller.
|
||||||
p
|
p
|
||||||
| The template above binds to a <code>name</code> property through the <code>{{ }}</code> syntax. In the component's constructor the name property is being set to Alice. When the template is rendered, Alice will appear instead of <code>{{ name }}</code>.
|
| The template above binds to a <code>name</code> property through the <code>{{ }}</code> syntax.The body of the constructor assigns "Alice" to the name property. When the template renders, Alice will appear instead of <code>{{ name }}</code>.
|
||||||
.clear
|
.clear
|
||||||
|
|
||||||
// STEP 4 - Bootstrap ##########################
|
// STEP 4 - Bootstrap ##########################
|
||||||
|
@ -133,13 +131,13 @@
|
||||||
|
|
||||||
h3#section-transpile Bootstrap
|
h3#section-transpile Bootstrap
|
||||||
p
|
p
|
||||||
| The last step to get the component to load on the page.
|
| The last step to load the component on the page.
|
||||||
|
|
||||||
section.docs-sub-section
|
section.docs-sub-section
|
||||||
h4 The <code>bootstrap</code> function
|
h4 The <code>bootstrap</code> function
|
||||||
.c6
|
.c6
|
||||||
p
|
p
|
||||||
| Angular provides a <code>bootstrap</code> function that renders your component to the page. The <code>bootstrap</code> function takes a component as a parameter. Any child components inside of the parent component will be rendered as well.
|
| Angular provides a <code>bootstrap</code> function that renders a component to the page. The <code>bootstrap</code> function takes a component as a parameter. Any child components inside of the parent component will render as well.
|
||||||
|
|
||||||
code
|
code
|
||||||
pre bootstrap(AppComponent);
|
pre bootstrap(AppComponent);
|
||||||
|
@ -153,7 +151,7 @@
|
||||||
|
|
||||||
h3#section-angular-create-account Declare the HTML
|
h3#section-angular-create-account Declare the HTML
|
||||||
p
|
p
|
||||||
| Create a <code>index.html</code> file at the root of the project. Include the <code>es6-shim.js</code> file in the <code>head</code> tag. Once the shim is included the <code>app</code> component can be declared in the HTML.
|
| Create an <code>index.html</code> file at the root of the project. Include the <code>es6-shim.js</code> file in the <code>head</code> tag. Now, declare the app component the <code>body</code>. The es6-shim must load before any application code.
|
||||||
|
|
||||||
code
|
code
|
||||||
pre
|
pre
|
||||||
|
@ -173,14 +171,17 @@
|
||||||
section.docs-sub-section
|
section.docs-sub-section
|
||||||
h4 Load the component module
|
h4 Load the component module
|
||||||
.c6
|
.c6
|
||||||
p
|
|
||||||
| The last step is to load the module for the <code>app</code> component. The <code>es6-shim</code> file comes packaged with the <code>System</code> library. <code>System</code> will allow you to load modules in browsers that do not support ES6 module loading.
|
|
||||||
|
|
||||||
p
|
p
|
||||||
| To load the needed modules, <code>System</code> needs to know where to dynamically load the files. The <code>paths</code> property in <code>System</code> allows you to specify where the location of the files.
|
| The last step is to load the module for the app component. The es6-shim file comes packaged with the System library. Most browsers today do not support ES6 module loading. System provides module loading functionality to these browsers.
|
||||||
|
|
||||||
p
|
p
|
||||||
| Using <code>System.paths</code> specify paths for Angular, runtime assertions, and the <code>app</code> component created above.
|
| To load the needed modules, System needs to know where to load the files from. The paths property in System specifies the location of the files.
|
||||||
|
|
||||||
|
p Tell System about three paths:
|
||||||
|
ol
|
||||||
|
li Angular - The Angular framework.
|
||||||
|
li Runtime assertions - Optional assertions for runtime type checking.
|
||||||
|
li The app component created above - The component to display on the page.
|
||||||
|
|
||||||
code
|
code
|
||||||
pre
|
pre
|
||||||
|
|
Loading…
Reference in New Issue