Formatting.
This commit is contained in:
parent
9fdb7b3dbb
commit
68ebf708fe
|
@ -30,13 +30,13 @@
|
||||||
header
|
header
|
||||||
|
|
||||||
h3#section-transpile Import Angular
|
h3#section-transpile Import Angular
|
||||||
p
|
p
|
||||||
| Create a new file named <code>app.es6</code>. The <code>.es6</code> extension signifies that the file uses ES6 syntax. Using the ES6 module syntax you can import the required modules from Angular2.
|
| Create a new file named <code>app.es6</code>. The <code>.es6</code> extension signifies that the file uses ES6 syntax. Using the ES6 module syntax you can import the required modules from Angular2.
|
||||||
pre
|
pre
|
||||||
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 basic pieces needed to create an Angular app. The import statement loads the modules dynamically at runtime.
|
||||||
|
|
||||||
// STEP 3 - Create a component ##########################
|
// STEP 3 - Create a component ##########################
|
||||||
.content-block.content-number.clearfix
|
.content-block.content-number.clearfix
|
||||||
|
@ -46,74 +46,74 @@
|
||||||
header
|
header
|
||||||
|
|
||||||
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>.
|
| 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>.
|
||||||
|
|
||||||
|
pre
|
||||||
|
code <hello></hello>
|
||||||
|
|
||||||
pre
|
p A <code>Component</code> is made up of two parts; the annotation section and the component controller.
|
||||||
code <hello></hello>
|
|
||||||
|
|
||||||
p A <code>Component</code> is made up of two parts; the annotation section and the component controller.
|
|
||||||
|
|
||||||
pre
|
|
||||||
code
|
|
||||||
| import {Component, Template, bootstrap} from 'angular2/angular2';
|
|
||||||
| @Component({
|
|
||||||
| selector: 'app'
|
|
||||||
| })
|
|
||||||
| @Template({
|
|
||||||
| inline: `
|
|
||||||
| <h1>Hello {{ name }}</h1>
|
|
||||||
| `
|
|
||||||
| })
|
|
||||||
| class AppComponent {
|
|
||||||
| constructor() {
|
|
||||||
| this.name = "Alice";
|
|
||||||
| }
|
|
||||||
| }
|
|
||||||
| bootstrap(App);
|
|
||||||
|
|
||||||
section.docs-sub-section
|
pre
|
||||||
h4 Component Annotations
|
code
|
||||||
.c6
|
| import {Component, Template, bootstrap} from 'angular2/angular2';
|
||||||
p
|
| @Component({
|
||||||
| The annotation section is where you can describe meta-data about your
|
| selector: 'app'
|
||||||
code component
|
| })
|
||||||
| You can always identify an annotation by its
|
| @Template({
|
||||||
code @
|
| inline: `
|
||||||
| sign. 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.
|
| <h1>Hello {{ name }}</h1>
|
||||||
p
|
| `
|
||||||
| The <code>Template</code> annotations 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 template.
|
| })
|
||||||
pre
|
| class AppComponent {
|
||||||
code
|
| constructor() {
|
||||||
| @Component({
|
| this.name = "Alice";
|
||||||
| selector: 'app'
|
| }
|
||||||
| })
|
| }
|
||||||
| @Template({
|
| bootstrap(App);
|
||||||
| inline: `
|
|
||||||
| <h1>Hello {{ name }}</h1>
|
section.docs-sub-section
|
||||||
| `
|
h4 Component Annotations
|
||||||
| })
|
.c6
|
||||||
p
|
p
|
||||||
| The <code>Component</code> created above will have a HTML tag of <code><app></app></code> and a template of <code><h1>Hello {{ name }}</h1></code>.
|
| The annotation section is where you can describe meta-data about your
|
||||||
.clear
|
code component
|
||||||
|
| You can always identify an annotation by its
|
||||||
section.docs-sub-section
|
code @
|
||||||
h4 Component Controller
|
| sign. 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.
|
||||||
.c6
|
p
|
||||||
p
|
| The <code>Template</code> annotations 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 template.
|
||||||
| The component controller is defined using the ES6 <code>class</code> syntax. This <code>class</code> is the backing of the component's template.
|
pre
|
||||||
pre
|
code
|
||||||
code
|
| @Component({
|
||||||
| class AppComponent {
|
| selector: 'app'
|
||||||
| constructor() {
|
| })
|
||||||
| this.name = "Alice";
|
| @Template({
|
||||||
| }
|
| inline: `
|
||||||
| }
|
| <h1>Hello {{ name }}</h1>
|
||||||
p
|
| `
|
||||||
| Templates read directly from their component controllers. Any properties or functions placed on the component controller can be directly accessed from the template.
|
| })
|
||||||
p
|
p
|
||||||
| In 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 <code>Component</code> created above will have a HTML tag of <code><app></app></code> and a template of <code><h1>Hello {{ name }}</h1></code>.
|
||||||
.clear
|
.clear
|
||||||
|
|
||||||
|
section.docs-sub-section
|
||||||
|
h4 Component Controller
|
||||||
|
.c6
|
||||||
|
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.
|
||||||
|
pre
|
||||||
|
code
|
||||||
|
| class AppComponent {
|
||||||
|
| constructor() {
|
||||||
|
| this.name = "Alice";
|
||||||
|
| }
|
||||||
|
| }
|
||||||
|
p
|
||||||
|
| Templates read directly from their component controllers. Any properties or functions placed on the component controller can be directly accessed from the template.
|
||||||
|
p
|
||||||
|
| In 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>.
|
||||||
|
.clear
|
||||||
|
|
||||||
// STEP 4 - Bootstrap ##########################
|
// STEP 4 - Bootstrap ##########################
|
||||||
.content-block.content-number.clearfix
|
.content-block.content-number.clearfix
|
||||||
|
@ -123,76 +123,79 @@
|
||||||
header
|
header
|
||||||
|
|
||||||
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 get the component to load 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 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.
|
||||||
|
|
||||||
code
|
code
|
||||||
pre bootstrap(App);
|
pre bootstrap(App);
|
||||||
.clear
|
.clear
|
||||||
|
|
||||||
// STEP 5 - Declare the HTML ##########################
|
// STEP 5 - Declare the HTML ##########################
|
||||||
.content-block.content-number.clearfix
|
.content-block.content-number.clearfix
|
||||||
i.number.icon-number5.large
|
i.number.icon-number5.large
|
||||||
.c11
|
.c11
|
||||||
header
|
header
|
||||||
|
|
||||||
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 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.
|
||||||
|
|
||||||
code
|
code
|
||||||
pre
|
pre
|
||||||
| <html>
|
| <html>
|
||||||
| <head>
|
| <head>
|
||||||
| <title>Angular 2 Quickstart</title>
|
| <title>Angular 2 Quickstart</title>
|
||||||
| </head>
|
| </head>
|
||||||
| <body>
|
| <body>
|
||||||
| <!-- -->
|
| <!-- -->
|
||||||
| <!-- The app component created in app.es6 -->
|
| <!-- The app component created in app.es6 -->
|
||||||
| <app></app>
|
| <app></app>
|
||||||
| <!-- -->
|
| <!-- -->
|
||||||
| </body>
|
| </body>
|
||||||
| </html>
|
| </html>
|
||||||
|
|
||||||
section.docs-sub-section
|
section.docs-sub-section
|
||||||
h4 Load the component module
|
h4 Load the component module
|
||||||
.c6
|
.c6
|
||||||
p
|
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, which is the current polyfill for ES6 module loading. <code>System</code> will allow you to load modules in browsers that do not support ES6 module loading.
|
| 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.
|
||||||
|
|
||||||
code
|
p
|
||||||
pre
|
| Using <code>System.paths</code> specify paths for Angular, runtime assertions, and the <code>app</code> component created above.
|
||||||
| <html>
|
|
||||||
| <head>
|
code
|
||||||
| <title>Angular 2 Quickstart</title>
|
pre
|
||||||
| </head>
|
| <html>
|
||||||
| <body>
|
| <head>
|
||||||
| <!-- -->
|
| <title>Angular 2 Quickstart</title>
|
||||||
| <!-- The app component created in app.es6 -->
|
| </head>
|
||||||
| <app></app>
|
| <body>
|
||||||
| <!-- -->
|
| <!-- -->
|
||||||
| <script>
|
| <!-- The app component created in app.es6 -->
|
||||||
| // Rewrite the paths to load the files
|
| <app></app>
|
||||||
| System.paths = {
|
| <!-- -->
|
||||||
| 'angular2/*':'/es6-shim/angular2/*.js',
|
| <script>
|
||||||
| 'rtts_assert/*': '/es6-shim/rtts_assert/*.js',
|
| // Rewrite the paths to load the files
|
||||||
| 'app': 'app.es6'
|
| System.paths = {
|
||||||
| };
|
| 'angular2/*':'/es6-shim/angular2/*.js',
|
||||||
| <!-- -->
|
| 'rtts_assert/*': '/es6-shim/rtts_assert/*.js',
|
||||||
| System.import('app');
|
| 'app': 'app.es6'
|
||||||
| </script>
|
| };
|
||||||
| </body>
|
| <!-- -->
|
||||||
| </html>
|
| System.import('app');
|
||||||
.clear
|
| </script>
|
||||||
|
| </body>
|
||||||
|
| </html>
|
||||||
|
.clear
|
||||||
|
|
||||||
.content-block.content-number.clearfix
|
.content-block.content-number.clearfix
|
||||||
i.number.icon-number6.large
|
i.number.icon-number6.large
|
||||||
|
@ -201,5 +204,5 @@
|
||||||
header
|
header
|
||||||
|
|
||||||
h3#section-transpile Extra-credit
|
h3#section-transpile Extra-credit
|
||||||
p
|
p
|
||||||
| Learn some template syntax for extra-credit.
|
| Learn some template syntax for extra-credit.
|
||||||
|
|
Loading…
Reference in New Issue