Last active
May 4, 2018 12:02
-
-
Save jrbalsas/de4883bacd081f54726aa420e101d696 to your computer and use it in GitHub Desktop.
Práctica angular
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('Club',[ 'ClientesControllerModule' /*otros módulos de la APP*/ ] ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1> Lista de clientes</h1> | |
<table> | |
<tr><td>Nombre</td><td>DNI</td><td>Socio</td></tr> | |
<tr data-ng-repeat="c in $ctrl.listaclientes" | |
data-ng-click="$ctrl.visualiza(c)" > | |
<td>{{c.nombre}}</td> <td>{{c.dni}}</td> | |
<td>{{c.socio}}</td> | |
</tr> | |
</table> | |
<blockquote data-ng-show="$ctrl.cliente.nombre.length>0"> | |
<h2>{{$ctrl.cliente.nombre}}</h2> | |
<p>DNI: {{$ctrl.cliente.dni}}</p> | |
<p>{{($ctrl.cliente.socio?’SÍ’:’NO’)}} es socio</p> | |
</blockquote> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ClientesCtrl { | |
constructor() { | |
this.nombre = "Desconocido"; | |
this.listaclientes = [ | |
{nombre: 'Carlos', dni: '12345678T', socio: true}, | |
{nombre: 'María', dni: '87654321G', socio: true}, | |
{nombre: 'Juan', dni: '12121212H', socio: false}]; | |
} | |
}; | |
angular.module('ClientesControllerModule',[] ) | |
.controller('ClientesCtrl', [ ClientesCtrl ]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="es"> | |
<head> | |
<script> | |
class ClientesCtrl () { //$scope no es necesario | |
constructor () { | |
this.listaclientes= [ | |
{nombre:'Carlos', dni:'12345678T', socio:true}, | |
{nombre:'María', dni:'87654321G', socio:true}, | |
{nombre:'Juan', dni:'12121212H', socio:false} ]; | |
} | |
}; | |
</script> | |
</head> | |
<body data-ng-app="" data-ng-controller="ClientesCtrl as $ctrl"> | |
<p>Hay un total de {{$ctrl.listaclientes.length}} clientes</p> | |
<p>{{$ctrl.listaclientes | json }}</p> | |
<script src="//ajax.googleapis.com/..."></script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<body data-ng-app="" | |
data-ng-controller="ClientesCtrl as $ctrl"> | |
<input data-ng-model="nombre"> {{$ctrl.nombre}} | |
<h1> Lista de clientes</h1> | |
<table> | |
<tr><td>Nombre</td><td>DNI</td><td>Socio</td></tr> | |
<tr data-ng-repeat="c in $ctrl.listaclientes"> | |
<td>{{c.nombre}}</td> <td>{{c.dni}}</td> | |
<td>{{c.socio}}</td> | |
</tr> | |
</table> | |
….. | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment