From 7b73d3d33dba622237d6b73d48de06583aca2b0f Mon Sep 17 00:00:00 2001 From: idoctnef Date: Thu, 6 Oct 2016 21:22:28 +0200 Subject: [PATCH] comments inside the travel json --- www/js/controllers.js | 7 ++++++- www/templates/travel.html | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/www/js/controllers.js b/www/js/controllers.js index 399b6d2..972591a 100644 --- a/www/js/controllers.js +++ b/www/js/controllers.js @@ -512,7 +512,7 @@ angular.module('starter.controllers', ['pascalprecht.translate']) $scope.newComment.commentAvatar=localStorage.getItem("c_avatar"); console.log($scope.newComment); $http({ - url: urlapi + 'travels/comment/' + $stateParams.travelId, + url: urlapi + 'travels/'+ $stateParams.travelId+'/comment', method: "POST", data: $scope.newComment }) @@ -520,6 +520,11 @@ console.log($scope.newComment); // success console.log("newComment added to server: " + response); console.log(response); + $scope.travels=response.data; + localStorage.setItem('c_travels', JSON.stringify($scope.travels)); + localStorage.setItem('c_travelsLastDate', JSON.stringify(new Date())); + $scope.travel = $filter('filter')($scope.travels, $stateParams.travelId, true)[0]; + if(response.data.success==false){ $ionicLoading.show({ template: 'failed to generate new asking package', noBackdrop: true, duration: 2000 }); diff --git a/www/templates/travel.html b/www/templates/travel.html index ad24a94..7e7116b 100644 --- a/www/templates/travel.html +++ b/www/templates/travel.html @@ -72,9 +72,9 @@
-
+
{{'Comments' | translate}}:
- +

{{comment.commentUsername}}

{{comment.comment}}