From c6fdff06c29885f3b3d18617df3ed8a875020cb2 Mon Sep 17 00:00:00 2001 From: idoctnef Date: Thu, 6 Oct 2016 14:48:46 +0200 Subject: [PATCH] travel detail from the current json, not from server --- config.xml | 8 ++++---- www/js/controllers.js | 15 ++++++++++----- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/config.xml b/config.xml index 77b4846..f4c7c70 100644 --- a/config.xml +++ b/config.xml @@ -1,11 +1,11 @@ - app + collectiveCar - An Ionic Framework and Cordova project. + CarSharing app, for collective use. - - Your Name Here + + ArnauCode diff --git a/www/js/controllers.js b/www/js/controllers.js index a407ba7..207321e 100644 --- a/www/js/controllers.js +++ b/www/js/controllers.js @@ -1,6 +1,6 @@ -//var urlapi="http://localhost:3000/api/"; -var urlapi="https://collectivecar.paas.primustech.io/api/"; +var urlapi="http://localhost:3000/api/"; +//var urlapi="https://collectivecar.paas.primustech.io/api/"; //localStorage.setItem("c_username", "user2"); @@ -107,6 +107,7 @@ angular.module('starter.controllers', ['pascalprecht.translate']) }, function(response) { // optional // failed + $ionicLoading.show({ template: 'Username already taken', noBackdrop: true, duration: 2000 }); }); }else{ $ionicLoading.show({ template: 'First complete all parameters', noBackdrop: true, duration: 2000 }); @@ -378,14 +379,14 @@ angular.module('starter.controllers', ['pascalprecht.translate']) }; }) -.controller('TravelCtrl', function($scope, $stateParams, $http, $ionicModal, $ionicPopup) { +.controller('TravelCtrl', function($scope, $stateParams, $http, $ionicModal, $ionicPopup, $filter) { if(localStorage.getItem('c_token')){// adding token to the headers $http.defaults.headers.common['X-Access-Token'] = localStorage.getItem('c_token'); } $scope.storageusername=localStorage.getItem("c_username"); $scope.travel=""; console.log($stateParams.travelId); - $http.get(urlapi + 'travels/'+$stateParams.travelId) + /*$http.get(urlapi + 'travels/'+$stateParams.travelId) .success(function(data, status, headers,config){ console.log('data success'); console.log(data); // for browser console @@ -398,7 +399,10 @@ angular.module('starter.controllers', ['pascalprecht.translate']) }) .then(function(result){ travel = result.data; - }); + });*/ + $scope.travels= JSON.parse(localStorage.getItem('c_travels')); + $scope.travel = $filter('filter')($scope.travels, $stateParams.travelId, true)[0]; + $scope.joins=""; $http.get(urlapi + 'travels/join/'+$stateParams.travelId) .success(function(data, status, headers,config){ console.log('data success'); @@ -536,6 +540,7 @@ console.log($scope.newComment); $scope.arrayObjectIndexOf = function(myArray, searchTerm, property) { + console.log(myArray+", "+searchTerm+", "+property); if(myArray) { for(var i = 0, len = myArray.length; i < len; i++) {