Skip to content

Instantly share code, notes, and snippets.

@leonardocouy
Forked from laocanio/app.js
Last active February 17, 2016 01:04
Show Gist options
  • Save leonardocouy/93f5d6e45860e7043591 to your computer and use it in GitHub Desktop.
Save leonardocouy/93f5d6e45860e7043591 to your computer and use it in GitHub Desktop.
PLACE
.controller ('ListarPacienteCtrl', function($scope,$ionicListDelegate,$ionicFilterBar, Paciente){
$scope.pacientes = Paciente.all()
$scope.listCanSwipe = true;
$scope.data = {
showDelete: false
};
$scope.onpacienteDelete = function(paciente) {
console.log(paciente.nombre)
Paciente.remove(paciente)
};
$scope.showFilterBar = function () {
$ionicFilterBar.show({
items: $scope.pacientes,
update: function (filteredItems) {
$scope.pacientes = filteredItems;
},
});
};
})
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<title></title>
<link href="lib/ionic/css/ionic.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
<!-- IF using Sass (run gulp sass first), then uncomment below and remove the CSS includes above
<link href="css/ionic.app.css" rel="stylesheet">
-->
<!-- ionic/angularjs js -->
<script src="lib/ionic/js/ionic.bundle.js"></script>
<!-- cordova script (this will be a 404 during development) -->
<script src="cordova.js"></script>
<!-- your app's js -->
<script src="js/app.js"></script>
<script src="js/controllers.js"></script>
<script src="js/services.js"></script>
<script src="lib/ngstorage/ngStorage.min.js"></script>
</head>
<body ng-app="starter">
<!--
The nav bar that will be updated as we navigate between views.
-->
<ion-nav-bar class="bar-stable">
<ion-nav-back-button>
</ion-nav-back-button>
</ion-nav-bar>
<!--
The views will be rendered in the <ion-nav-view> directive below
Templates are in the /templates folder (but you could also
have templates inline in this html file if you'd like).
-->
<ion-nav-view></ion-nav-view>
</body>
</html>
<ion-view view-title="Paciente">
<ion-content class="padding">
<ion-list>
<p>
{{paciente.nombre}}</p>
<p>
{{paciente.apellidos}}</p>
<p>
{{paciente.edad}}</p>
<p>
{{paciente.estatura}}</p>
<p>
{{paciente.peso}}</p>
<p>
{{paciente.presion}}</p>
</ion-item>
</ion-content>
</ion-view>
angular.module('starter.services', ['ngStorage'])
.factory('Paciente', function($localStorage) {
// Might use a resource here that returns a JSON array
// Some fake testing data
return {
all: function() {
return $localStorage.pacientes;
},
save: function(paciente) {
if(!$localStorage.pacientes){
$localStorage.pacientes = []
}
$localStorage.pacientes.push(paciente);
},
newProject: function(pacientes) {
// Add a new project
return {
name: ''
};
},
get: function(nombrePaciente) {
for (var i = 0; i < $localStorage.pacientes.length; i++) {
if ($localStorage.pacientes[i].nombre === nombrePaciente) {
return $localStorage.pacientes[i];
}
}
return null;
},
remove: function(paciente) {
$localStorage.pacientes.splice($localStorage.pacientes.indexOf(paciente.nombre))
},
update: function(paciente) {
var id_paciente = $localStorage.pacientes.indexOf(paciente)
$localStorage.pacientes[id_paciente] = paciente
},
}
});
<ion-view view-title="Lista de paciente">
<ion-nav-buttons side="right">
<div class="buttons">
<button class="button button-icon ion-android-search" ng-click="showFilterBar()"></button>
</div>
</ion-nav-buttons>
<ion-content >
<ion-list show-delete="data.showDelete" type="item-text-wrap" can-swipe="listCanSwipe">
<ion-item ng-repeat="paciente in pacientes"
href="#/tab/listarpaciente/{{paciente.nombre}}">
<p> {{paciente.nombre}}</p>
<p>{{paciente.apellidos}}</p>
<ion-delete-button class="ion-minus-circled"
ng-click="onpacienteDelete(paciente)">
</ion-delete-button>
</ion-item>
</ion-content>
</ion-view>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment