Skip to content

Commit 373d163

Browse files
committed
Página de perfil
Se usan más profundamente las directivas incluídas en Angularjs y se anidan controladores
1 parent bdeef6a commit 373d163

File tree

3 files changed

+62
-9
lines changed

3 files changed

+62
-9
lines changed

app/index.html

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ <h2>Lista Contactos</h2>
2424
</div>
2525
<div class="row">
2626
<div class="col-xs-12">
27-
<input type="text" ng-model="busqueda" class="form-control" placeholder="Filtrar resultados">
27+
<input type="text" ng-model="busqueda" class="form-control" placeholder="Filtrar resultados" ng-change="contactos.mostrarPerfil(-1)">
2828
</div>
2929
</div>
3030
<table class="table table-hover table-striped table-clickable">
@@ -37,14 +37,28 @@ <h2>Lista Contactos</h2>
3737
</tr>
3838
</thead>
3939
<tbody>
40-
<tr ng-repeat="contacto in contactos.contactosArray | filter:busqueda" class="row">
41-
<td class="col-xs-3" ng-bind-html="contacto.thumb"></td>
40+
<tr ng-repeat="contacto in contactos.contactosArray | filter:busqueda" class="row" ng-click="contactos.mostrarPerfil($index)">
41+
<td class="col-xs-3" ng-bind-html="contacto.icon"></td>
4242
<td class="col-xs-3">{{contacto.nombre}}</td>
4343
<td class="col-xs-3">{{contacto.apellido}}</td>
4444
<td class="col-xs-3"><a target="_blank" ng-href="https://twitter.com/{{contacto.contacto}}">{{contacto.contacto}}</a></td>
4545
</tr>
4646
</tbody>
4747
</table>
48+
<div class="container" ng-controller="PerfilCtrl as perfil" ng-show="contactos.isPerfilActivo()">
49+
<div class="row">
50+
<div class="col-xs-8">
51+
<h3>Perfil de {{contactos.contactosArray[contactos.perfilActivo].nombre}}</h3>
52+
<span class="img-thumbnail perfil-thumb text-center" ng-bind-html="contactos.contactosArray[contactos.perfilActivo].icon"></span>
53+
</div>
54+
<div class="col-xs-4 text-right">
55+
<h3 ng-click="contactos.mostrarPerfil(-1)" class="btn btn-default">
56+
<span class="glyphicon glyphicon-chevron-left"></span>
57+
<span>volver</span>
58+
</h3>
59+
</div>
60+
</div>
61+
</div>
4862
</div>
4963
</div>
5064
<div class="row">

app/scripts/app.js

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,44 @@ app.controller('PrincipalCtrl',['$scope',function($scope){
88
}]);
99

1010
app.controller('ContactosCtrl',['$scope',function($scope){
11+
this.perfilActivo = -1;
12+
1113
this.contactosArray = [
12-
{nombre: 'Axel', apellido: 'Salmeron', contacto: '@axulsr', thumb: '<span class="glyphicon glyphicon-user"></span>'},
13-
{nombre: 'Guillermo', apellido: 'Seminario', contacto: '@gjseminario', thumb: '<span class="glyphicon glyphicon-user"></span>'},
14-
{nombre: 'Alexander', apellido: 'Rondón', contacto: '@arondn2', thumb: '<span class="glyphicon glyphicon-user"></span>'},
15-
{nombre: 'José', apellido: 'Salazar', contacto: '@jslzrt', thumb: '<span class="glyphicon glyphicon-user"></span>'},
16-
{nombre: 'Marlys', apellido: 'Villafranca', contacto: '@MarlysitaV', thumb: '<span class="glyphicon glyphicon-user"></span>'},
17-
{nombre: 'Katrina', apellido: 'Ortiz', contacto: '@KatrinaOrtiz', thumb: '<span class="glyphicon glyphicon-user"></span>'}
14+
{nombre: 'Axel', apellido: 'Salmeron', contacto: '@axulsr',
15+
icon: '<span class="glyphicon glyphicon-user"></span>',
16+
thumb:''},
17+
18+
19+
{nombre: 'Guillermo', apellido: 'Seminario', contacto: '@gjseminario',
20+
icon: '<span class="glyphicon glyphicon-user"></span>',
21+
thumb:''},
22+
23+
{nombre: 'Alexander', apellido: 'Rondón', contacto: '@arondn2',
24+
icon: '<span class="glyphicon glyphicon-user"></span>',
25+
thumb:''},
26+
27+
{nombre: 'José', apellido: 'Salazar', contacto: '@jslzrt',
28+
icon: '<span class="glyphicon glyphicon-user"></span>',
29+
thumb:''},
30+
31+
{nombre: 'Marlys', apellido: 'Villafranca', contacto: '@MarlysitaV',
32+
icon: '<span class="glyphicon glyphicon-user"></span>',
33+
thumb:''},
34+
35+
{nombre: 'Katrina', apellido: 'Ortiz', contacto: '@KatrinaOrtiz',
36+
icon: '<span class="glyphicon glyphicon-user"></span>',
37+
thumb:''}
1838
];
39+
40+
this.mostrarPerfil = function(indice){
41+
this.perfilActivo = indice;
42+
};
43+
44+
this.isPerfilActivo = function(){
45+
return (this.perfilActivo==-1) ? false : true;
46+
};
47+
}]);
48+
49+
app.controller('PerfilCtrl',['$scope',function($scope){
50+
this.perfil = '';
1951
}]);

app/styles/styles.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,11 @@ body{
99
}
1010
.table.table-clickable tr{
1111
cursor: pointer;
12+
}
13+
.perfil-thumb{
14+
height: 100px;
15+
width: 100px;
16+
}
17+
.perfil-thumb span{
18+
font-size: 90px;
1219
}

0 commit comments

Comments
 (0)