Skip to content

Commit d14c948

Browse files
committed
Primera Subida
1 parent d91eab2 commit d14c948

File tree

11 files changed

+227
-531
lines changed

11 files changed

+227
-531
lines changed

src/app/app.component.html

Lines changed: 3 additions & 529 deletions
Large diffs are not rendered by default.

src/app/app.component.ts

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

src/app/app.module.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,18 @@ 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+
9+
610
@NgModule({
711
declarations: [
812
AppComponent
913
],
1014
imports: [
11-
BrowserModule
15+
BrowserModule,
16+
HeroesModule,
17+
ContadorModule
1218
],
1319
providers: [],
1420
bootstrap: [AppComponent]

src/app/contador/contador.module.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { CommonModule } from '@angular/common';
2+
import { NgModule } from '@angular/core';
3+
import { ContadorComponent } from './contador/contador.component';
4+
5+
6+
@NgModule({
7+
declarations: [
8+
ContadorComponent
9+
],
10+
exports: [
11+
ContadorComponent
12+
],
13+
imports: [
14+
CommonModule
15+
]
16+
})
17+
18+
19+
export class ContadorModule{
20+
21+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { Component } from '@angular/core';
2+
3+
@Component({
4+
selector: 'app-contador',
5+
template: `
6+
<h1>{{ title }}</h1>
7+
<span>{{ numero }}</span>
8+
<br>
9+
<button (click)="acumular(base)">+{{base}}</button>
10+
<button (click)="acumular(-base)">-{{base}}</button>
11+
`
12+
})
13+
14+
export class ContadorComponent {
15+
16+
title: string = 'Contador App';
17+
18+
numero: number = 10;
19+
20+
base: number = 5;
21+
22+
23+
acumular( valor: number){
24+
this.numero += valor;
25+
}
26+
27+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{{ nombre }}
2+
3+
<dl>
4+
<td>
5+
Nombre:
6+
</td>
7+
<dd>
8+
{{ nombre }}
9+
</dd>
10+
<td>
11+
Edad:
12+
</td>
13+
<dd>
14+
{{ edad }}
15+
</dd>
16+
17+
<td>
18+
Función:
19+
</td>
20+
<dd>
21+
{{ obtenerNombre() }}
22+
</dd>
23+
24+
<td>
25+
Capitalizado
26+
</td>
27+
28+
<dd>
29+
{{ nombreCapitalizado }}
30+
</dd>
31+
</dl>
32+
33+
<button (click)="cambiarNombre()">
34+
Cambiar Héroe
35+
</button>
36+
37+
<button (click)="cambiarEdad()">
38+
Cambiar Edad
39+
</button>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { Component } from "@angular/core";
2+
3+
4+
@Component ({
5+
selector: 'app-heroe',
6+
templateUrl: 'heroe.component.html'
7+
})
8+
9+
export class HeroeComponent{
10+
11+
public nombre: string = 'Ironman';
12+
public edad: number = 45;
13+
14+
get nombreCapitalizado():string{
15+
return this.nombre.toUpperCase();
16+
}
17+
18+
obtenerNombre():string{
19+
return `${ this.nombre } - ${ this.edad }`;
20+
}
21+
22+
cambiarNombre():void {
23+
this.nombre = 'Spiderman';
24+
}
25+
26+
cambiarEdad():void{
27+
this.edad = 30;
28+
}
29+
30+
}

src/app/heroes/heroes.module.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
19+
20+
export class HeroesModule{
21+
22+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
<p>Listado Herores</p>
3+
4+
<div *ngIf="heroeBorrado; else noBorrado">
5+
<h3>Herroe Borrado</h3>
6+
<small>{{ heroeBorrado }}</small>
7+
</div>
8+
9+
<ng-template #noBorrado>
10+
<h3>No ha borrado nada</h3>
11+
</ng-template>
12+
13+
<button (click)="borrarHeroe()">Borrar Heroe</button>
14+
15+
<ul>
16+
<li *ngFor="let heroe of heroes;let i = index">
17+
{{ i +1 }} - {{ heroe }}
18+
</li>
19+
</ul>
20+
21+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { Component } from '@angular/core';
2+
3+
@Component({
4+
selector: 'app-listado',
5+
templateUrl: './listado.component.html'
6+
})
7+
export class ListadoComponent {
8+
9+
public heroes: string[ ]= ['Goku', 'Vegeta', 'Gohan', 'Picolo'];
10+
public heroeBorrado: string = '';
11+
12+
borrarHeroe(){
13+
this.heroeBorrado = this.heroes.shift() || '';
14+
}
15+
16+
}

0 commit comments

Comments
 (0)