Skip to content

Commit a5b2818

Browse files
committed
actualizando un pequeno bug
1 parent 3e1b78d commit a5b2818

File tree

6 files changed

+40
-28
lines changed

6 files changed

+40
-28
lines changed

listado-personas/src/app/app-routing.module.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { NgModule } from '@angular/core';
22
import { Routes, RouterModule } from '@angular/router';
3+
import { PersonaComponent } from './personas/persona/persona.component';
34
import { PersonasComponent } from './personas/personas.component';
45
import { FormularioComponent } from './personas/formulario/formulario.component';
56
import { ErrorComponent } from './error/error.component';

listado-personas/src/app/data.service.ts

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import { Injectable } from '@angular/core';
22
import { HttpClient, HttpResponse } from '@angular/common/http';
33
import { Persona } from './persona.model';
4-
import { PersonasService } from './personas.service';
5-
import { Subscriber } from 'rxjs';
64

75
@Injectable()
86
export class DataService {
@@ -32,7 +30,10 @@ export class DataService {
3230
modificarPersona(index: number, persona: Persona) {
3331
let url: string;
3432
url =
35-
'https://listado-personas.firebaseio.com' + '/datos/' + index + '.json';
33+
'https://listado-personas-3624c-default-rtdb.firebaseio.com' +
34+
'/datos/' +
35+
index +
36+
'.json';
3637
console.log('url de modificarPersona:' + url);
3738
this.httpClient.put(url, persona).subscribe(
3839
(response) => {
@@ -45,7 +46,10 @@ export class DataService {
4546
eliminarPersona(index: number) {
4647
let url: string;
4748
url =
48-
'https://listado-personas.firebaseio.com' + '/datos/' + index + '.json';
49+
'https://listado-personas-3624c-default-rtdb.firebaseio.com' +
50+
'/datos/' +
51+
index +
52+
'.json';
4953
console.log('url de eliminarPersona:' + url);
5054
this.httpClient.delete(url).subscribe(
5155
(response) => {
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
21
<div class="item">
32
<ul>
43
<li>
5-
<a
6-
[routerLink]="['/personas',indice]"
7-
[queryParams]="{modoEdicion:'1'}">
8-
{{persona.nombre}} {{persona.apellido}}</a>
4+
<a
5+
[routerLink]="['/personas', indice]"
6+
[queryParams]="{ modoEdicion: '1' }"
7+
>
8+
{{ persona.nombre }} {{ persona.apellido }}</a
9+
>
910
</li>
1011
</ul>
11-
</div>
12+
</div>

listado-personas/src/app/personas/persona/persona.component.ts

+4-6
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,14 @@ import { Component, OnInit, Input } from '@angular/core';
22
import { Persona } from '../../persona.model';
33
import { PersonasService } from '../../personas.service';
44

5-
@Component({
6-
selector: 'app-persona',
5+
@Component({
6+
selector: 'app-persona',
77
templateUrl: './persona.component.html',
8-
styleUrls: ['./persona.component.css']
8+
styleUrls: ['./persona.component.css'],
99
})
1010
export class PersonaComponent implements OnInit {
1111
@Input() persona: Persona;
1212
@Input() indice: number;
1313

14-
ngOnInit() {
15-
}
16-
14+
ngOnInit() {}
1715
}

listado-personas/src/app/personas/personas.component.ts

+16-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import { Component, OnInit } from '@angular/core';
22
import { Persona } from '../persona.model';
3+
import { LoggingService } from '../LoggingService.service';
34
import { PersonasService } from '../personas.service';
4-
import { Router } from '@angular/router';
5+
import { Router, ActivatedRoute } from '@angular/router';
6+
import { map } from 'rxjs/operators';
57

68
@Component({
79
selector: 'app-personas',
@@ -12,17 +14,22 @@ export class PersonasComponent implements OnInit {
1214
personas: Persona[] = [];
1315

1416
constructor(
17+
private loggingService: LoggingService,
1518
private personasService: PersonasService,
16-
private router: Router
19+
private router: Router,
20+
private route: ActivatedRoute
1721
) {}
1822

19-
ngOnInit() {
20-
this.personasService.obtenerPersonas().subscribe((personas: any) => {
21-
//Cargamos los datos de la base de datos al arreglo de personas local
22-
this.personas = personas;
23-
this.personasService.setPersonas(this.personas);
24-
console.log('obtener personas suscriber:' + this.personas);
25-
});
23+
ngOnInit(): void {
24+
this.personasService
25+
.obtenerPersonas()
26+
27+
.subscribe((personas1: any) => {
28+
//Cargamos los datos de la base de datos al arreglo de personas local
29+
this.personas = personas1;
30+
this.personasService.setPersonas(this.personas);
31+
console.log('obtener personas suscriber:' + personas1);
32+
});
2633
}
2734

2835
irAgregar() {

listado-personas/src/main.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import { enableProdMode } from '@angular/core';
22
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
33

4-
import { AppModule } from './app/app.module';
54
import { environment } from './environments/environment';
5+
import { AppModule } from './app/app.module';
66

77
if (environment.production) {
88
enableProdMode();
99
}
1010

11-
platformBrowserDynamic().bootstrapModule(AppModule)
12-
.catch(err => console.error(err));
11+
platformBrowserDynamic()
12+
.bootstrapModule(AppModule)
13+
.catch((err) => console.error(err));

0 commit comments

Comments
 (0)