include ../../../../_includes/_util-fns
:marked
The Developers Guide is a practical guide to Angular for experienced programmers who
are building client applications in HTML and JavaScript.
figure
img(src="/resources/images/devguide/intro/people.png" alt="Us" align="left" style="width:200px; margin-left:-40px;margin-right:10px" )
:marked
We are on a journey together to understand how Angular works and, more importantly,
how to make it work for us. We look at our application requirements and we see problems to solve.
* How do we get data onto the screen and handle user interactions?
* How do we organize our code into manageable, cohesive chunks of functionality that work together?
* What are the essential Angular building blocks and how do they help?
* How do we minimize routine, mechanical coding in favor of declarative, higher level constructs without losing control?
This chapter begins the journey. It's an introduction to Angular in two parts.
1. [How to read this guide](#how-to-read)
2. [An architecture overview](#architecture)
.l-main-section
:marked
# How to Read this Guide
The chapters of this guide target an Angular feature and how to use it to solve a programming problem.
Every chapter includes code snippets ... snippets we can reuse in our own applications.
Typically, these snippets are excerpts from a running sample application that accompanies the chapter.
We can often find a link to a live version of that sample near the top of the chapter ... like this one.
[Live Example](/resources/live-examples/intro/ts/src/plnkr.html)
This link opens in a browser and runs the sample code supporting this chapter's architecture overview.
We can inspect, modify, save, and download the code.
A few chapters are written as tutorials and are clearly marked as such.
Most chapters are *not* tutorials and do not explain how to build the accompanying sample.
These chapters highlight key points in code but generally don't include the entire source.
We can get that by way of the live link.
We don't have to read this guide straight through.
The "[Cheat Sheet](cheatsheet.html)" is a handy map to Angular overall.
A few early chapters are arranged sequentially and best read together to establish a foundation in Angular.
But most chapters stand on their own. We can browse to any of them as our interest or some necessity moves us.
There is a learning path for those of us who are new to Angular.
It starts *outside* the guide with the [QuickStart](../quickstart). The QuickStart is the "Hello, World" of Angular 2.
It shows us how to setup the libraries and tools we'll need to write *any* Angular app.
It ends with a "proof of life", a running Angular app.
The [Tutorial](../tutorial) is our next stop.
It walks us step-by-step from where QuickStart leaves off to a simple data-driven app. Simple, yes, but with
the essential characteristics we'd expect of a professional application:
a sensible project structure, data binding, master/detail, services, dependency injection, navigation, and remote data access.
The final iteration of the "[Tour of Heroes](#toh)" is a positive answer to that most important question:
***can we build an Angular 2 application that does what we need it to do?***
We suggest continuing from the "Tour of Heroes" tutorial to the early core chapters of this Developers Guide in the following order:
1. [Displaying Data](displaying-data.html)
1. [User Input](user-input.html)
1. [Forms](forms.html)
1. [Dependency Injection](dependency-injection.html)
We might pause at that point to absorb what we've learned and perhaps experiment on our own before diving into [Template Syntax](template-syntax.html).
That chapter is rather dense. It's also essential reading at some point and
we will return to it frequently as we compose our HTML templates, both for understanding and as a reference.
Follow your own star from there, wherever it leads.
.l-main-section
:marked
# Architecture Overview
Angular 2 is a framework to help us build client applications in HTML and JavaScript.
The framework consists of several cooperating libraries, some of them core and some optional.
We write applications by composing HTML *templates* with Angularized-markup,
writing *component* classes to manage those templates, adding application logic in *services*,
and handing the top root component to Angular's *bootstrapper*.
Angular takes over, presenting our application content in a browser and responding to user interactions
according to the instructions we provided.
figure
img(src="/resources/images/devguide/intro/airplane.png" alt="Us" align="left" style="width:200px; margin-left:-40px;margin-right:10px" )
:marked
Of course there is more to it than this.
We're cruising at high altitude in this overview.
We're looking for landmarks. We should expect the object below to be fuzzy and obscured by occasional clouds.
Details become more clear and precise when we land in the chapters themselves.
:marked
An Angular 2 application rests on seven main building blocks:
1. [Component](#component)
1. [Template](#template)
1. [Metadata](#metadata)
1. [Data Binding](#data-binding)
1. [Directive](#directive)
1. [Service](#service)
1. [Dependency Injection](#dependency-injection)
figure
img(src="/resources/images/devguide/intro/overview.png" alt="overview" style="margin-left:-40px;" )
:marked
Learn these seven and we're on our way.
.l-main-section
:marked
## The Component
figure
img(src="/resources/images/devguide/intro/hero-component.png" alt="Component" align="left" style="width:200px; margin-left:-40px;margin-right:10px" )
:marked
A **Component** controls a patch of screen real estate that we could call a *view*.
The shell at the application root with navigation links, that list of heroes, the hero editor ...
they're all views controlled by Components.
We define a Component's application logic - what it does to support the view - inside a class.
The class interacts with the view through an API of properties and methods.
A `HeroListComponent`, for example, might have a `heroes` property that returns an array of heroes
that it acquired from a service.
It might have a `selectHero()` method that sets a `selectedHero` property when the user click on a hero from that list.
It might be a class like this:
+makeExample('intro/ts/src/app/hero-list.component.ts', 'class')
:marked
Angular creates, updates, and destroys components as the user moves through the application.
The developer can take action at each moment in this lifecycle through optional [Lifecycle Hooks](#).
.l-sub-section
:marked
We're not showing those hooks in this example
but we are making a mental note to find out about them later.
We may wonder who is calling that constructor? Who provides the service parameter?
For the moment, have faith that Angular will call the constructor and deliver an
appropriate `HeroService` when we need it.
.l-main-section
:marked
## The Template
figure
img(src="/resources/images/devguide/intro/template.png" alt="Template" align="left" style="width:200px; margin-left:-40px;margin-right:10px" )
:marked
We define a Component's view with its companion **template**. A template is a form of HTML
that tells Angular how to render the Component.
A template looks like regular HTML much of the time ... and then it gets a bit strange. Here is a
template for our `HeroList` component
+makeExample('intro/ts/src/app/hero-list.component.html')
:marked
We recognize `
{{hero.name}}
, `(click)`, `[hero]`, and `Metadata tells Angular how to process a class.
{{hero.name}}
"[interpolation](displaying-data.html#interpolation)"
displays the component's `hero.name` property value within the `