Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- angular.module('perfilEstu', ['ionic', 'ngCordova'])
- .controller('perfilEstudiante', perfilEstudiante)
- .factory('obtenerPerfil', obtenerPerfil);
- perfilEstudiante.$inject = ['$scope', 'obtenerPerfil'];
- function perfilEstudiante($scope, obtenerPerfil) {
- var Perfil, fila, i, l_perfil, db, sqlConsulta;
- obtenerPerfil.datosPerfil().then(function(data){
- Perfil = data;
- $scope.Cedula = Perfil.cedula;
- $scope.Nombre = Perfil.nombre;
- $scope.Apellido = Perfil.apellido;
- $scope.Rol = Perfil.Rol;
- $scope.Facultad = Perfil.facultad;
- $scope.Programa = Perfil.programa;
- $scope.Semestre = Perfil.semestre;
- });
- };
- obtenerPerfil.$inject = ['$cordovaSQLite', '$q'];
- function obtenerPerfil($cordovaSQLite, $q) {
- return {
- datosPerfil: function (){
- var sqlConsulta, db, perfil, datos, l_perfil, i, fila;
- //deferObject = deferObject || $q.defer();
- sqlConsulta = "SELECT * FROM Estudiante"
- perfil = {};
- db = $cordovaSQLite.openDB({ name: "unicesar.db" });
- perfil = $cordovaSQLite.execute(db, sqlConsulta, []).then(function(resultado) {
- l_perfil = resultado.rows.length;
- for(i=0 ; i<l_perfil ; i++){
- fila = resultado.rows.item(i);
- datos = {
- cedula: fila.Cedula,
- nombre: fila.Nombre,
- apellido: fila.Apellido,
- rol: "Estudiante",
- facultad: fila.Facultad,
- programa: fila.Programa,
- semestre: fila.Semestre
- };
- }
- return datos;
- }, function (err) {
- console.error(err);
- });
- return perfil;
- }
- };
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement