---
title: Angular 2 Starter Project
localeTitle: Angular 2 Starter Project
---
Este tutorial construirá un proyecto semilla extremadamente simple con Angular2. Comenzaremos con la aplicación más básica posible y luego agregaremos un poco más de funcionalidad.
## Visión de conjunto
Las aplicaciones de Angular 2 se crean mediante la creación de plantillas HTML que contienen marcas específicas angulares. Luego se crean clases para administrar las plantillas y todo se envuelve en un módulo, que se unen para crear su aplicación. Estos módulos se conocen como **componentes** .
Angular interpreta estos módulos y los utiliza para presentar su aplicación en el navegador.
## Aplicación de arranque
Vamos a empezar con una aplicación mínima. Comenzaremos con una aplicación que contiene un único módulo cuyo único trabajo es mostrar texto.
Comenzaremos creando una nueva carpeta llamada "app".
```
$ mkdir app
```
Como se mencionó anteriormente, nuestra aplicación comenzará con un único módulo o **componente** que mostrará texto en la pantalla. Podemos usar tanto JavaScript puro como TypeScript para hacer una aplicación angular 2. Usando TypeScript, es más fácil y más fácil de programar. ![:wink:](//forum.freecodecamp.com/images/emoji/emoji_one/wink.png?v=2 ":guiño:")
Aprendamos cómo crear un componente usando TypeScript.
Cree un archivo llamado _`app.component.ts`_ como se muestra:
```
// app.component.ts
import { Component } from '@angular/core';
@Component({
selector: 'my-app',
template: '
`,
styles: [`
.counter {
width: 100%;
margin: auto;
background: darkgreen;
border-radius: 5px;
color: white;
padding: 20px;
text-align: center;
}
.counter h1 {
margin: 0;
padding: 20px;
font-size: 36px;
}
.counter button {
background: #f1c40f;
border: 0;
box-shadow: 0px 5px 0px #927608;
padding: 20px;
width: 100%;
outline: none;
border-radius: 5px;
color: darkgreen;
font-weight: bold;
}
.counter button:hover {
background: #a9890a;
cursor: pointer;
}
`]
})
export class IncrementClicker {
curClicks = 0;
incrementClicks() {
this.curClicks++;
}
}
```
Our component structure is similar to our previous one, but we've added a bit of functionality here. You will notice our class is no longer empty. We've added a variable to track the clicks as well as a function to increment them when the user clicks the button.
You can display properties from your class in your template using double braces such as: `{{ variableName }}`
We bind the button click event to our class function using Angulars Event Bindings.
```html
```
Notice that we've also added some styling to our components. This way everything is self-contained in this module. You may also include a `templateUrl` and/or `styleUrls` properties instead to extract the template and style rules to an external file and link them here.
Now we just need to update our `AppComponent` to include our new component:
```js
// app/app.component.ts
import { Component } from '@angular/core';
/* Nested Component */
import { IncrementClicker } from 'app/increment-clicker.component';
@Component({
selector: 'my-app',
directives: [IncrementClicker],
template: `
Free Code Camp Rocks!
`,
styles: [`
h1 { color: darkgreen; font-family: Arial, Helvetica, sans-serif;}
`]
})
export class AppComponent { }
```
To pull in our new `IncrementClicker` component we need to import it by including the class name as well as the location of the typescript file as we did on this line:
```js
import { IncrementClicker } from 'app/increment-clicker.component';
```
We then add the `IncrementClicker` *component* as a directive to the `AppComponent` module using:
```js
directives: [IncrementClicker],
```
Finalmente, simplemente agregamos la etiqueta a la que se conecta nuestro componente en la plantilla. Por lo tanto, el selector en nuestro componente `IncrementClicker` coincidirá con la etiqueta donde queremos que aparezca.
`js template:`
# Free Code Camp Rocks!
`,`
¡Nuestro componente ahora está incluido en nuestra aplicación!
\[Código actualizado
[VER APLICACIÓN COMPLETA](http://run.plnkr.co/plunks/BdvNONEmO3Jwg0EavX22/)