File tree Expand file tree Collapse file tree 12 files changed +237
-550
lines changed
Expand file tree Collapse file tree 12 files changed +237
-550
lines changed Load Diff Large diffs are not rendered by default.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -2,9 +2,13 @@ import { Component } from '@angular/core';
22
33@Component ( {
44 selector : 'app-root' ,
5- templateUrl : './app.component.html' ,
6- styleUrls : [ './app.component.css' ]
5+ templateUrl : 'app.component.html'
6+ // template: `
7+ // <h1>Hola de nuevo</h1>
8+
9+ // `
710} )
11+
812export class AppComponent {
9- title = 'bases' ;
13+
1014}
Original file line number Diff line number Diff line change @@ -3,12 +3,17 @@ import { BrowserModule } from '@angular/platform-browser';
33
44import { AppComponent } from './app.component' ;
55
6+ import { ContadorModule } from './contador/contador.module'
7+ import { HeroesModule } from './heroes/heroes.module' ;
8+
69@NgModule ( {
710 declarations : [
8- AppComponent
11+ AppComponent ,
912 ] ,
1013 imports : [
11- BrowserModule
14+ BrowserModule ,
15+ ContadorModule ,
16+ HeroesModule
1217 ] ,
1318 providers : [ ] ,
1419 bootstrap : [ AppComponent ]
Original file line number Diff line number Diff line change 1+ import { NgModule } from "@angular/core" ;
2+ import { contadorComponent } from './contador/contador.component' ;
3+
4+ @NgModule ( {
5+ declarations : [
6+ contadorComponent
7+ ] ,
8+ exports : [
9+ contadorComponent
10+ ]
11+ } )
12+
13+ export class ContadorModule {
14+
15+ }
Original file line number Diff line number Diff line change 1+ import { Component } from '@angular/core' ;
2+
3+ @Component ( {
4+ selector : 'app-contador' ,
5+ template : `
6+ <h1>{{ titulo }}</h1>
7+
8+ <!-- <button (click) = " numero = numero + 1 "> + 1 </button>
9+ <span>{{ numero }}</span>
10+ <button (click) = " numero = numero - 1 "> - 1 </button> -->
11+
12+ <!-- <button (click) = "sumar()"> + 1 </button>
13+ <span>{{ numero }}</span>
14+ <button (click) = "restar()"> - 1 </button> -->
15+
16+ <h4>Acumular with integer</h4>
17+ <button (click) = "acumular(2)"> + 1 </button>
18+ <span>{{ numero }}</span>
19+ <button (click) = "acumular(-2)"> - 1 </button>
20+
21+ <h3>La base es: <strong>{{base}}</strong></h3>
22+ <h4>Acumular with propiedad de la clase</h4>
23+ <button (click) = "acumular(base)"> + {{base}}</button>
24+ <span>{{ numero }}</span>
25+ <button (click) = "acumular(-base)"> - {{base}}</button>
26+ `
27+ } )
28+
29+ export class contadorComponent {
30+ titulo : string = 'Contador App' ;
31+ numero : number = 10 ;
32+ base : number = 5 ;
33+
34+ // sumar () {
35+ // this.numero += 1
36+ // }
37+ // restar () {
38+ // this.numero -= 1
39+ // }
40+ //
41+ //better approach
42+ acumular ( valor : number ) {
43+ this . numero += valor ;
44+ }
45+ }
Original file line number Diff line number Diff line change 1+ < h1 > {{ nombre }}</ h1 >
2+
3+ < dl >
4+ < td > Nombre: </ td >
5+ < dd > {{ nombre }}</ dd >
6+
7+ < td > Edad: </ td >
8+ < dd > {{ edad }}</ dd >
9+
10+ < td > Función: </ td >
11+ < dd > {{ obtenerNombre() }}</ dd >
12+
13+ < td > Capitalizado: </ td >
14+ <!-- <dd>{{ nombre.toUpperCase() }}</dd> -->
15+ < dd > {{ nombreCapitalizado }}</ dd >
16+ </ dl >
17+
18+ < button (click) ='cambiarNombre() '>
19+ Cambiar Héroe
20+ </ button >
21+
22+ < button (click) ='cambiarEdad() '>
23+ Cambiar edad
24+ </ button >
Original file line number Diff line number Diff line change 1+ import { Component } from "@angular/core" ;
2+
3+ @Component ( {
4+ selector : 'app-heroe' ,
5+ templateUrl : 'heroe.component.html'
6+ } )
7+ export class HeroeComponent {
8+
9+ nombre : string = 'Ironman' ;
10+ edad : number = 45 ;
11+
12+ get nombreCapitalizado ( ) : string {
13+ return this . nombre . toUpperCase ( ) ;
14+ }
15+
16+ obtenerNombre ( ) : string {
17+ return `${ this . nombre } - ${ this . edad } `
18+ // return this.nombre + ' - ' + this.edad;
19+ }
20+
21+ cambiarNombre ( ) : void {
22+ this . nombre = 'Spiderman' ;
23+ }
24+
25+ cambiarEdad ( ) : void {
26+ this . edad = 30 ;
27+ }
28+ }
Original file line number Diff line number Diff line change 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+ export class HeroesModule {
20+
21+ }
Original file line number Diff line number Diff line change 1+ < p > Listado de Héroes</ p >
2+
3+ <!-- <div *ngIf="heroeBorrado !== ''"> -->
4+ <!-- <div *ngIf="heroeBorrado.length"> -->
5+ < div *ngIf ="heroeBorrado; else noBorrado ">
6+ < h3 > Héroe borrado:
7+ < small > {{ heroeBorrado }}</ small >
8+ </ h3 >
9+ </ div >
10+
11+ < ng-template #noBorrado >
12+ < h3 > No ha borrado nada.</ h3 >
13+ </ ng-template >
14+
15+ < button (click) ="borrarHeroe() ">
16+ Borrar Héroe
17+ </ button >
18+
19+ < ul >
20+ < li *ngFor ="let heroe of heroes; let i = index ">
21+ {{i}} - {{heroe}}
22+ </ li >
23+ </ ul >
24+
You can’t perform that action at this time.
0 commit comments