Skip to content

Commit 0e4778f

Browse files
committed
Creación de módulo de controladores
se crea un módulo para los controladores y se inyecta en el módulo principal
1 parent 373d163 commit 0e4778f

File tree

3 files changed

+52
-51
lines changed

3 files changed

+52
-51
lines changed

app/index.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ <h1>{{principal.tituloApp}}</h1>
2222
<h2>Lista Contactos</h2>
2323
</div>
2424
</div>
25-
<div class="row">
25+
<div class="row" ng-show="!contactos.isPerfilActivo()">
2626
<div class="col-xs-12">
2727
<input type="text" ng-model="busqueda" class="form-control" placeholder="Filtrar resultados" ng-change="contactos.mostrarPerfil(-1)">
2828
</div>
2929
</div>
30-
<table class="table table-hover table-striped table-clickable">
30+
<table class="table table-hover table-striped table-clickable" ng-show="!contactos.isPerfilActivo(-1)">
3131
<thead>
3232
<tr class="row">
3333
<th class="col-xs-3">Icono</th>
@@ -69,5 +69,6 @@ <h3 ng-click="contactos.mostrarPerfil(-1)" class="btn btn-default">
6969
<script src="bower_components/angular/angular.min.js"></script>
7070
<script src="bower_components/angular-sanitize/angular-sanitize.js"></script>
7171
<script src="scripts/app.js"></script>
72+
<script src="scripts/controladores.js"></script>
7273
</body>
7374
</html>

app/scripts/app.js

Lines changed: 3 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,5 @@
11
'use strict';
22
var app = angular.module('angularFromScratch', [
3-
'ngSanitize'
4-
]);
5-
6-
app.controller('PrincipalCtrl',['$scope',function($scope){
7-
this.tituloApp = 'Hola AngularJS';
8-
}]);
9-
10-
app.controller('ContactosCtrl',['$scope',function($scope){
11-
this.perfilActivo = -1;
12-
13-
this.contactosArray = [
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:''}
38-
];
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 = '';
51-
}]);
3+
'ngSanitize',
4+
'app.controladores'
5+
]);

app/scripts/controladores.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
'use strict';
2+
angular.module('app.controladores', [])
3+
.controller('PrincipalCtrl',['$scope',function($scope){
4+
this.tituloApp = 'Hola AngularJS';
5+
}])
6+
.controller('ContactosCtrl',['$scope',function($scope){
7+
this.perfilActivo = -1;
8+
9+
this.contactosArray = [
10+
{nombre: 'Axel', apellido: 'Salmeron', contacto: '@axulsr',
11+
icon: '<span class="glyphicon glyphicon-user"></span>',
12+
thumb:''},
13+
14+
15+
{nombre: 'Guillermo', apellido: 'Seminario', contacto: '@gjseminario',
16+
icon: '<span class="glyphicon glyphicon-user"></span>',
17+
thumb:''},
18+
19+
{nombre: 'Alexander', apellido: 'Rondón', contacto: '@arondn2',
20+
icon: '<span class="glyphicon glyphicon-user"></span>',
21+
thumb:''},
22+
23+
{nombre: 'José', apellido: 'Salazar', contacto: '@jslzrt',
24+
icon: '<span class="glyphicon glyphicon-user"></span>',
25+
thumb:''},
26+
27+
{nombre: 'Marlys', apellido: 'Villafranca', contacto: '@MarlysitaV',
28+
icon: '<span class="glyphicon glyphicon-user"></span>',
29+
thumb:''},
30+
31+
{nombre: 'Katrina', apellido: 'Ortiz', contacto: '@KatrinaOrtiz',
32+
icon: '<span class="glyphicon glyphicon-user"></span>',
33+
thumb:''}
34+
];
35+
36+
this.mostrarPerfil = function(indice){
37+
this.perfilActivo = indice;
38+
};
39+
40+
this.isPerfilActivo = function(){
41+
return (this.perfilActivo==-1) ? false : true;
42+
};
43+
}])
44+
.controller('PerfilCtrl',['$scope',function($scope){
45+
this.perfil = '';
46+
}]);

0 commit comments

Comments
 (0)