diff --git a/app/www/js/controllers.js b/app/www/js/controllers.js
index 5abe9ac..a10e19b 100644
--- a/app/www/js/controllers.js
+++ b/app/www/js/controllers.js
@@ -1,7 +1,13 @@
+
+//var urlapi="http://localhost:3000/api/";
+var urlapi="http://192.168.1.40:3000/api/";
+localStorage.setItem("c_username", "user2");
+localStorage.setItem("c_token", "");
+
+
angular.module('starter.controllers', [])
.controller('AppCtrl', function($scope, $ionicModal, $timeout) {
-
// With the new view caching in Ionic, Controllers are only called
// when they are recreated or on app start, instead of every page change.
// To listen for when this page is active (for example, to refresh data),
@@ -48,7 +54,7 @@ angular.module('starter.controllers', [])
$scope.travels=JSON.parse(localStorage.getItem('c_travels'));
$scope.doRefresh = function() {
- $http.get('http://localhost:3000/api/travels')
+ $http.get(urlapi + 'travels')
.success(function(data, status, headers,config){
console.log('data success');
console.log(data); // for browser console
@@ -116,12 +122,12 @@ angular.module('starter.controllers', [])
console.log('Doing new travel', $scope.newtravel);
$scope.newtravel.icon="lorry";
$scope.newtravel.generateddate=$scope.newtravel.date;
- $scope.newtravel.owner="user";
+ $scope.newtravel.owner=localStorage.getItem("c_username");
$scope.newtravel.modality="offering";
console.log($scope.newtravel);
$http({
- url: 'http://localhost:3000/api/travels',
+ url: urlapi + 'travels',
method: "POST",
data: $scope.newtravel
})
@@ -148,12 +154,12 @@ angular.module('starter.controllers', [])
console.log('Doing new travel', $scope.newtravel);
$scope.newtravel.icon="lorry";
$scope.newtravel.generateddate=$scope.newtravel.date;
- $scope.newtravel.owner="user";
+ $scope.newtravel.owner=localStorage.getItem("c_username");
$scope.newtravel.modality="asking";
console.log($scope.newtravel);
$http({
- url: 'http://localhost:3000/api/travels',
+ url: urlapi + 'travels',
method: "POST",
data: $scope.newtravel
})
@@ -179,13 +185,13 @@ angular.module('starter.controllers', [])
console.log('Doing new package', $scope.newtravel);
$scope.newtravel.icon="lorry";
$scope.newtravel.generateddate=$scope.newtravel.date;
- $scope.newtravel.owner="user";
+ $scope.newtravel.owner=localStorage.getItem("c_username");
$scope.newtravel.package=true;
$scope.newtravel.modality="package";
console.log($scope.newtravel);
$http({
- url: 'http://localhost:3000/api/travels',
+ url: urlapi + 'travels',
method: "POST",
data: $scope.newtravel
})
@@ -209,9 +215,10 @@ angular.module('starter.controllers', [])
})
.controller('TravelCtrl', function($scope, $stateParams, $http) {
+ $scope.storageusername=localStorage.getItem("c_username");
$scope.travel="";
console.log($stateParams.travelId);
- $http.get('http://localhost:3000/api/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
@@ -231,7 +238,7 @@ angular.module('starter.controllers', [])
$scope.users=JSON.parse(localStorage.getItem('c_users'));
$scope.doRefresh = function() {
- $http.get('http://localhost:3000/api/users')
+ $http.get(urlapi + 'users')
.success(function(data, status, headers, config){
console.log('data success');
console.log(data); // for browser console
@@ -250,9 +257,9 @@ angular.module('starter.controllers', [])
})
.controller('UserCtrl', function($scope, $stateParams, $http) {
- $scope.travel="";
+ //$scope.user="";
console.log($stateParams.username);
- $http.get('http://localhost:3000/api/users/byusername/'+$stateParams.username)
+ $http.get(urlapi + 'users/byusername/'+$stateParams.username)
.success(function(data, status, headers,config){
console.log('data success');
console.log(data); // for browser console
@@ -261,6 +268,19 @@ angular.module('starter.controllers', [])
.error(function(data, status, headers,config){
console.log('data error');
})
+ .then(function(result){
+ user = result.data;
+ });
+
+ $http.get(urlapi + 'travels/user/'+$stateParams.username)
+ .success(function(data, status, headers,config){
+ console.log('data success');
+ console.log(data); // for browser console
+ $scope.travels = data; // for UI
+ })
+ .error(function(data, status, headers,config){
+ console.log('data error');
+ })
.then(function(result){
travels = result.data;
});
diff --git a/app/www/templates/newaskingtravel.html b/app/www/templates/newaskingtravel.html
index 088e8b2..a666169 100644
--- a/app/www/templates/newaskingtravel.html
+++ b/app/www/templates/newaskingtravel.html
@@ -2,7 +2,7 @@
-
+
New Asking Travel {{newtravel.title}}
+
Ask to join Offer car + Offer car +
++ Delete
diff --git a/app/www/templates/travels.html b/app/www/templates/travels.html index e35e3b5..fff5c0c 100644 --- a/app/www/templates/travels.html +++ b/app/www/templates/travels.html @@ -14,15 +14,16 @@{{travel.description}}
nºseats: {{travel.seats}}
nºpeople: {{travel.seats}}
-nºseats: {{travel.seats}}
+nºpeople: {{travel.seats}}
++ {{travel.description}} +
+ + + +