.l-main-section
  h2#section-install-or-plunker Install Angular
  p There are four steps to create any Angular app:
  ol
    li Create an entry point HTML file where users will start
    li Load the Angular library at the top of the file
    li Make a root component for your application
    li Bootstrap Angular
  p.
    You can edit and test out your apps by serving local files with a web server. Follow the steps in the quickstart to get Typescript setup.
  p.
    When you're serving local files, edit and save them and start a web server that serves files in that directory.  If you have Python installed, you can run a basic HTTP server from the root of your code directory with:
  pre.prettyprint.lang-bash
    code python -m SimpleHTTPServer 8000
.callout.is-helpful
  header Typescript vs ES5
  p.
    Although we work through the examples in TypeScript, you can also use
    regular ES5. Click the ES5 link in any code box to see the ES5 JavaScript
    version. Note that in ES5, you'd want to name your files .js rather than
    .ts.
.l-main-section
  h2#section-create-an-entry-point Create an entry point
  p.
    Create an index.html file and add the Angular library tags and a main.ts file where
    you'll build your first component.
  p.
    In the <body>, add an element called <my-app> that will be the root of your
    application.
  p.
    The TypeScript setup includes System.js, a third-party open-source library that adds ES6 module loading functionality to browsers. This step isn't needed for the ES5 version.
  code-tabs
    code-pane(language="html" name="TypeScript" format="linenums").
      <!DOCTYPE html>
      <html>
        <head>
          <script src="https://jspm.io/system@0.16.js"></script>
          <script src="https://code.angularjs.org/2.0.0-alpha.23/angular2.dev.js"></script>
        </head>
        <body>
          <my-app></my-app>
          <script>
            System.import('main');
          </script>
        </body>
      </html>
    code-pane(language="html" name="ES5" format="linenums").
      <!DOCTYPE html>
      <html>
        <head>
          <script src="https://code.angularjs.org/2.0.0-alpha.23/angular2.sfx.dev.js"></script>
          <script src="main.js"></script>
        </head>
        <body>
          <my-app></my-app>
        </body>
      </html>
.callout.is-helpful
  header Don't use code.angularjs.org in a live app
  p.
    This example serves the Angular library from code.angularjs.org. This is
    fine for examples, but you'd want to serve it yourself or use a CDN for real deployment.
.l-main-section
  h2#section-set-up-the-starting-component Set up the starting component
  p.
    In main.ts, create a class called AppComponent, configure it to bind to the
    <my-app> element in index.html, and call Angular's bootstrap() to kick
    it all off like this:
  code-tabs
    code-pane(language="javascript" name="TypeScript" format="linenums").
      import {Component, View, bootstrap} from 'angular2/angular2';
      @Component({
        selector: 'my-app'
      })
      @View({
        template: '<h1>My first Angular 2 App</h1>'
      })
      class AppComponent {
      }
      bootstrap(AppComponent);
    code-pane(language="javascript" name="ES5" format="linenums").
        function AppComponent() {}
        AppComponent.annotations = [
          new angular.ComponentAnnotation({
            selector: 'my-app'
          }),
          new angular.ViewAnnotation({
            template: '<h1>My first Angular 2 App</h1>'
          })
        ];
        document.addEventListener('DOMContentLoaded', function() {
          angular.bootstrap(AppComponent);
        });
  .callout.is-helpful
    header Annotations vs Decorators
    p.
      If you are transpiling using a tool that translates the @ symbols to
      annotations (for example Traceur), you will need to import the annotation versions of
      Component and View. That can be easily achieved using
      import {ComponentAnnotation as Component, ViewAnnotation as View}.
.l-main-section
  h2#section-run-it Run it!
  p.
    Open index.html through your web server and you should see:
  figure.image-display
    img(src='/resources/images/examples/setup-example1.png' alt="Example of Todo App")
.l-main-section
  h2#section-explanations Explanations
  p This basic Angular app contains the structure for any app you'll build.
  .l-sub-section
    h3 It's all a tree
    p.
      You can think of Angular apps as a tree of components.  This root component we've been talking about acts as the top
      level container for the rest of your application.  You've named this one AppComponent, but there's
      nothing special about the name and you can use whatever makes sense to you.
    p.
      The root component's job is to give a location in the index.html file where your application will
      render through its element, in this case <my-app>.  There is also nothing special about this
      element name; you can pick it as you like.
    p.
      The root component loads the initial template for the application that will load other components to perform
      whatever functions your application needs - menu bars, views, forms, etc.  We'll walk through examples of all of
      these in the following pages.
  .l-sub-section
    h3 @Component and @View annotations
    p.
      A component annotation describes details about the component. An annotation can be identified by its at-sign (@).
    p.
      The @Component annotation defines the HTML tag for the component by specifying the component's CSS selector.
    p.
      The @View annotation defines the HTML that represents the component. The component you wrote uses an inline template, but you can also have an external template. To use an external template, specify a templateUrl property and give it the path to the HTML file.
  .l-sub-section
    h3 import vs. window.angular
    p.
      The main difference between the ES5 and TypeScript versions is the loading of modules.
    strong TypeScript
    p.
      TypeScript supports ES6 module loading syntax. ES6 modules allow for modular loading of JavaScript code. Using ES6 modules you can cherry-pick only what you need for your app.
    strong ES5
    p.
      In ES5 the script file creates an angular property on the window of the browser. This property contains every piece of Angular core, whether you need it or not.
    code-tabs
      code-pane(language="javascript" name="TypeScript" format="linenums" ).
        import {Component, View, bootstrap} from 'angular2/angular2';
        ...
        // bootstrap is available for use because it was imported from angular core
        bootstrap(AppComponent);
      code-pane(language="javascript" name="ES5" format="linenums").
        // window.angular is available because the script file attaches the angular property to the window
        document.addEventListener('DOMContentLoaded', function() {
          angular.bootstrap(AppComponent);
        });