Skip to content

Commit

Permalink
mostrando lista de usuarios
Browse files Browse the repository at this point in the history
  • Loading branch information
pablo384 committed Sep 19, 2018
1 parent e99b4d3 commit 38f6925
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
15 changes: 12 additions & 3 deletions src/app/usuarios/lista/lista.component.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
<p>
lista works!
</p>
<div class="card-columns">
<div class="card" *ngFor="let user of usuarios">
<img class="card-img-top" [src]="user.avatar">
<div class="card-body">
<h5 class="card-title">{{user.first_name}} {{user.last_name}}</h5>
<p class="card-text">
This content is a little bit longer.</p>
<p class="card-text">
<span class="text-muted">ID: {{user.id}}</span></p>
</div>
</div>
</div>
7 changes: 6 additions & 1 deletion src/app/usuarios/lista/lista.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Component, OnInit } from '@angular/core';
import { UsuarioService } from '../../services/usuario.service';
import { Usuario } from '../../models/usuario.model';

@Component({
selector: 'app-lista',
Expand All @@ -8,13 +9,17 @@ import { UsuarioService } from '../../services/usuario.service';
})
export class ListaComponent implements OnInit {

usuarios: Usuario[] = [];
constructor(
public userS: UsuarioService
) { }

ngOnInit() {
this.userS.getUsers().subscribe(
users => console.log(users)
users => {
this.usuarios = users;
console.log(users);
}
);
}

Expand Down

0 comments on commit 38f6925

Please sign in to comment.