Skip to content

Commit

Permalink
Introducción a Angular
Browse files Browse the repository at this point in the history
  • Loading branch information
leandrotomassini committed Feb 8, 2022
1 parent 5eb5066 commit ea7d6a7
Show file tree
Hide file tree
Showing 11 changed files with 11,355 additions and 72 deletions.
11,290 changes: 11,259 additions & 31 deletions workspace/01-Bases/package-lock.json

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions workspace/01-Bases/src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<!-- <app-contador></app-contador> -->
<app-contador></app-contador>

<app-heroe></app-heroe>
<!-- <app-heroe></app-heroe> -->
<!-- <app-listado></app-listado> -->
31 changes: 0 additions & 31 deletions workspace/01-Bases/src/app/app.component.spec.ts

This file was deleted.

14 changes: 8 additions & 6 deletions workspace/01-Bases/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@ import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';

import { AppComponent } from './app.component';
import { ContadorComponent } from './contador/contador.component';
import { HeroeComponent } from './heroes/heroe/herore.component';
import { ContadorModule } from './contador/contador.module';

import { HeoresModule } from './heroes/heroes.module';


@NgModule({
declarations: [
AppComponent,
ContadorComponent,
HeroeComponent
AppComponent
],
imports: [
BrowserModule
BrowserModule,
HeoresModule,
ContadorModule
],
providers: [],
bootstrap: [AppComponent]
Expand Down
18 changes: 18 additions & 0 deletions workspace/01-Bases/src/app/contador/contador.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { ContadorComponent } from './contador/contador.component';



@NgModule({
declarations: [
ContadorComponent
],
exports: [
ContadorComponent
],
imports: [
CommonModule
]
})
export class ContadorModule { }
8 changes: 6 additions & 2 deletions workspace/01-Bases/src/app/heroes/heroe/heroe.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,9 @@ <h1>{{ nombre }}</h1>
<dd>{{ nombreCapitalizado }}</dd>
</dl>

<button (click)="cambiarNombre()">Cambiar Heroe</button>
<button>Cambiar edad</button>
<button (click)="cambiarNombre()">
Cambiar Heroe
</button>
<button (click)="cambiarEdad()">
Cambiar edad
</button>
4 changes: 4 additions & 0 deletions workspace/01-Bases/src/app/heroes/heroe/herore.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,8 @@ export class HeroeComponent {
cambiarNombre(): void {
this.nombre = 'Spiderman';
}

cambiarEdad():void{
this.edad = 30;
}
}
19 changes: 19 additions & 0 deletions workspace/01-Bases/src/app/heroes/heroes.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';

import { HeroeComponent } from './heroe/herore.component';
import { ListadoComponent } from './listado/listado.component';

@NgModule({
declarations: [
HeroeComponent,
ListadoComponent
],
exports: [
ListadoComponent
],
imports: [
CommonModule
]
})
export class HeoresModule {}
22 changes: 22 additions & 0 deletions workspace/01-Bases/src/app/heroes/listado/listado.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<p>Listado de Héroes</p>
<div>

<p *ngIf="heroeBorrado; else noBorrado">
Héroe borrado: <small> {{ heroeBorrado }}</small>
</p>

<ng-template #noBorrado>
<p>No ha borrado nada.</p>
</ng-template>

<button (click)="borrarHeroe()" *ngIf="heroes.length > 0">
Borrar
</button>

<ul>
<li *ngFor="let heroe of heroes; let i = index">
{{ i + 1 }} {{ heroe }}
</li>
</ul>

</div>
16 changes: 16 additions & 0 deletions workspace/01-Bases/src/app/heroes/listado/listado.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Component } from '@angular/core';

@Component({
selector: 'app-listado',
templateUrl: './listado.component.html'
})
export class ListadoComponent {

heroes: string[] = ['Spiderman', 'Iron man', 'Hulk', 'Thor', 'Capitán América'];
heroeBorrado: string = '';

borrarHeroe() {
this.heroeBorrado = this.heroes.shift() || 'No hay más héroes.';
}

}

0 comments on commit ea7d6a7

Please sign in to comment.