Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- HTML /////////////////////////////
- <div class="modal-footer">
- <div class="col-xs-4"> {{servicio.horaSelect.horaInicioFin.hora }}</div>
- <div class="col-xs-4"></div>
- <div class="col-xs-4">
- </div>
- </div>
- //////////////////77
- .controller('modalNewCitaController', function ($scope, servicio) {
- $scope.servicio = servicio;
- })
- .factory('servicio', function ($rootScope) {
- //esta haciendo el servicio para ver si me resultava ..
- var nuevaCita = {};
- var horaSelect = [];
- var horaInicioFin ={};
- function activo(dia, hora, eventos) {
- var c = moment(dia).format('MM/DD/YYYY');
- var valor = false;
- angular.forEach(eventos, function (value, key) {
- var fechaEv = moment(value.startsAt).format('MM/DD/YYYY');
- if (fechaEv === c) {
- var horaEv = moment(value.startsAt).format('HH:mm');
- if (horaEv === hora.hora) {
- valor = true;
- } else {
- }
- }
- });
- return valor;
- }
- function select(dia,hora,$index) {
- if(!hora.selected){
- hora.selected = true;
- hora.index = $index;
- horaSelect.push({
- hora:hora.hora,
- fecha: moment(dia).format('MM/DD/YYYY')
- }
- );
- // var desde = moment([2010,10,10,8,00]);
- // var to = moment([2010,10,10,9,46]);
- // console.log(to.diff(desde, 'minute'));
- var inicio = horaSelect.sort(function(a, b){return a.hora.replace(':','') - b.hora.replace(':','')}) ;
- var fin = horaSelect[horaSelect.length - 1];;
- var cadena = fin.hora.split(':');
- var finMenosUno = parseInt(cadena[1]) + 14;
- horaSelect.horaInicioFin = {};
- horaSelect.horaInicioFin = {hora:inicio[0].hora + ' - ' +cadena[0]+':'+finMenosUno};
- if(horaSelect.length > 0)
- {
- $rootScope.siguiente = true;
- }
- }
- else
- {
- hora.selected = false;
- angular.forEach(horaSelect, function (value, key) {
- if(value.hora === hora.hora){
- horaSelect.splice(key, 1);
- }
- });
- if(horaSelect.length == 0){
- $rootScope.siguiente = false;
- }
- }
- }
- return {
- horaSelect : horaSelect,
- horaInicioFin:horaInicioFin,
- Activo: activo,
- Select: select
- };
- })
Advertisement
Add Comment
Please, Sign In to add comment