Skip to content

Commit

Permalink
58.listado_de_personajes
Browse files Browse the repository at this point in the history
  • Loading branch information
verdizone committed Feb 23, 2021
1 parent bb4a853 commit a123c77
Show file tree
Hide file tree
Showing 8 changed files with 131 additions and 533 deletions.
533 changes: 1 addition & 532 deletions src/app/app.component.html

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { DbzModule } from './dbz/dbz.module';

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

Expand All @@ -8,7 +9,9 @@ import { AppComponent } from './app.component';
AppComponent
],
imports: [
BrowserModule
BrowserModule,
DbzModule,

],
providers: [],
bootstrap: [AppComponent]
Expand Down
18 changes: 18 additions & 0 deletions src/app/dbz/dbz.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 { FormsModule } from '@angular/forms';

import { MainPageComponent } from './main-page/main-page.component';


@NgModule({
declarations: [MainPageComponent],
exports:[
MainPageComponent
],
imports: [
CommonModule,
FormsModule,
]
})
export class DbzModule { }
10 changes: 10 additions & 0 deletions src/app/dbz/interfaces/dbz.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
Esta interface es para que generemos
un objeto para los personajes de la app
*/

interface Personajes{
nombre: string,
poder: number,

}
45 changes: 45 additions & 0 deletions src/app/dbz/main-page/main-page.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<div class="container main-container">

<h1>Dragon Ball Z</h1>
<hr>

<div class="row">
<div class="col">
<h3>Personajes</h3>
<hr>
<ul *ngFor="let personaje of personajes">

<li>{{ personaje.nombre }} - {{personaje.poder|number}}</li>
</ul>
</div>
<div class="col">
<h3>Agregar</h3>
<hr>
<form (ngSubmit)="agregar()">
<input
type="text"
placeholder="Nombre"
class="form-control"
name="nombre"
[(ngModel)]=" nuevo.nombre"
>

<input
type="number"
placeholder="Poder"
class="form-control"
name="poder"
[(ngModel)]=" nuevo.poder"
>

<br>
<button type="submit"
class="btn btn-outline-primary w-100">
Agregar...
</button>
</form>

</div>
</div>

</div>
44 changes: 44 additions & 0 deletions src/app/dbz/main-page/main-page.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { Component } from '@angular/core';
import '../interfaces/dbz.interface'


@Component({
selector: 'app-main-page',
templateUrl: './main-page.component.html'
})
export class MainPageComponent {

personajes:Personajes[] = [
{
nombre:'Krilin',
poder: 800,
},
{
nombre:'Goku',
poder: 14500,
}
];

nuevo:Personajes = {
nombre: '',
poder: 0,
}

agregar(){

if(this.nuevo.nombre.trim().length===0){ return; }

console.log(this.nuevo);
// this.peronajes.push(this.nuevo);
this.personajes.push(this.nuevo);
this.nuevo = {
nombre:'',
poder:0,
}



}


}
4 changes: 4 additions & 0 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<!-- CSS only -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BmbxuPwQa2lc/FVzBcNJ7UAyJxM6wuqIj61tLrc4wSX0szH/Ev+nYRRuWlolflfl" crossorigin="anonymous">
</head>
<body>
<app-root></app-root>
<!-- JavaScript Bundle with Popper -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta2/dist/js/bootstrap.bundle.min.js" integrity="sha384-b5kHyXgcpbZJO/tY9Ul7kGkf1S0CWuKcCD38l8YkeH8z8QjE0GmW1gYU5S9FOnJ0" crossorigin="anonymous"></script>
</body>
</html>
5 changes: 5 additions & 0 deletions src/styles.css
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
/* You can add global styles to this file, and also import other style files */


.main-container{
margin-top: 30px;
}

0 comments on commit a123c77

Please sign in to comment.