Skip to content

Commit 69d43e5

Browse files
committed
primer commit
1 parent 80cdd19 commit 69d43e5

File tree

12 files changed

+204
-547
lines changed

12 files changed

+204
-547
lines changed

src/app/app.component.html

Lines changed: 2 additions & 513 deletions
Large diffs are not rendered by default.

src/app/app.component.spec.ts

Lines changed: 0 additions & 31 deletions
This file was deleted.

src/app/app.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ import { Component } from '@angular/core';
66
styleUrls: ['./app.component.css']
77
})
88
export class AppComponent {
9-
title = 'bases';
9+
10+
1011
}

src/app/app.module.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,17 @@ import { BrowserModule } from '@angular/platform-browser';
33

44
import { AppComponent } from './app.component';
55

6+
import { HeroesModule } from './heroes/heroes.module';
7+
import { ContadorModule } from './contador/contador.module';
8+
69
@NgModule({
710
declarations: [
811
AppComponent
912
],
1013
imports: [
11-
BrowserModule
14+
BrowserModule,
15+
HeroesModule,
16+
ContadorModule
1217
],
1318
providers: [],
1419
bootstrap: [AppComponent]
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { ContadorComponent } from './contador/contador.component';
2+
import { NgModule } from '@angular/core';
3+
4+
@NgModule({
5+
declarations: [
6+
ContadorComponent
7+
],
8+
exports: [
9+
ContadorComponent
10+
],
11+
imports: [
12+
13+
]
14+
})
15+
export class ContadorModule{}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { Component } from '@angular/core';
2+
3+
@Component({
4+
selector: 'app-contador',
5+
template: `
6+
<h1>David</h1>
7+
<h2> {{ titulo }} </h2>
8+
9+
<h3>la base es <strong>{{base}}</strong> </h3>
10+
<button (click)="acumular(base)" > aumentar base</button>
11+
<button (click)="acumular(-base)" > disminuir base</button>
12+
<p>
13+
<button (click)="acumular(1)">+1</button>
14+
<span> {{numero}} </span>
15+
<button (click)="acumular(-1);" >-1</button>
16+
`
17+
})
18+
export class ContadorComponent{
19+
public titulo : string = 'contador app';
20+
numero: number = 10;
21+
base: number = 5;
22+
23+
sumar(){
24+
this.numero++;
25+
}
26+
restar(){
27+
this.numero--;
28+
}
29+
acumular(valor: number){
30+
this.numero += valor;
31+
}
32+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<h1>{{nombre}}</h1>
2+
<dl>
3+
<td> Nombre: </td>
4+
<dd> {{nombre}} </dd>
5+
6+
<td> Edad: </td>
7+
<dd> {{edad}} </dd>
8+
9+
<td> Funcion: </td>
10+
<dd> {{obtenerNombre()}} </dd>
11+
12+
<td> Capitalizado: </td>
13+
<dd> {{ nombreCapitalizado }} </dd>
14+
</dl>
15+
16+
<button (click)='cambiarNombre()' >Cambiar heroe</button>
17+
18+
<button (click)='cambiarEdad()' >Cambiar edad</button>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { Component } from "@angular/core";
2+
3+
@Component({
4+
selector: 'app-heroe',
5+
templateUrl: 'heroe.component.html'
6+
})
7+
export class HeroeComponent{
8+
nombre: string = 'Ironman';
9+
edad: number = 45;
10+
11+
12+
obtenerNombre():string{
13+
return `${ this.nombre } - ${this.edad}`
14+
}
15+
16+
get nombreCapitalizado(): string{
17+
return this.nombre.toUpperCase();
18+
}
19+
20+
cambiarNombre(): void{
21+
this.nombre = 'Spiderman';
22+
}
23+
cambiarEdad(): void{
24+
this.edad = 30;
25+
}
26+
27+
28+
29+
}

src/app/heroes/heroes.module.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { CommonModule } from '@angular/common';
2+
import { NgModule } from '@angular/core';
3+
import { HeroeComponent } from './heroe/heroe.component';
4+
import { ListadoComponent } from './listado/listado.component';
5+
6+
@NgModule({
7+
declarations: [
8+
HeroeComponent,
9+
ListadoComponent
10+
],
11+
exports: [
12+
ListadoComponent
13+
],
14+
imports: [
15+
CommonModule
16+
]
17+
})
18+
export class HeroesModule{}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<p>listado heroes</p>
2+
3+
<div *ngIf="hb; else noBorrar">
4+
<h3> Heroe Borrado <small> {{hb}} </small></h3>
5+
</div>
6+
<ng-template #noBorrar>
7+
<h3> No ha borrado nada </h3>
8+
</ng-template>
9+
10+
11+
12+
<button (click)="hb=borrarHeroe()" >
13+
Borrar
14+
</button>
15+
16+
<ul>
17+
<li *ngFor="let heroe of heroes; let i=index">
18+
{{i+1}} {{heroe}}
19+
</li>
20+
</ul>
21+
22+

0 commit comments

Comments
 (0)