From 8b1e678202f64f53d9260c19d75cd8775760a68b Mon Sep 17 00:00:00 2001 From: arnaucode Date: Fri, 24 Feb 2017 00:33:16 +0100 Subject: [PATCH] newEvent categories selection implemented, and image by url (temporalment) --- www/js/newEvent.js | 30 +++++++++++++++++++++++++++++- www/templates/newEvent.html | 21 ++++++++++----------- 2 files changed, 39 insertions(+), 12 deletions(-) diff --git a/www/js/newEvent.js b/www/js/newEvent.js index 238a3fb..90821a0 100644 --- a/www/js/newEvent.js +++ b/www/js/newEvent.js @@ -3,8 +3,10 @@ angular.module('app.newEvent', ['pascalprecht.translate', 'ui-leaflet']) .controller('NewEventCtrl', function($scope, $http, $ionicModal, $timeout, $ionicLoading, $filter, leafletData, leafletBoundsHelpers) { + + //initialization $scope.event={}; - $scope.event.categories=[{name: "prova"}]; + $scope.event.categories=[]; $scope.event.location={ direction: "", geo: { @@ -13,6 +15,32 @@ angular.module('app.newEvent', ['pascalprecht.translate', 'ui-leaflet']) name: "" } }; + + //get list of categories + $scope.categories; + $http.get(urlapi + 'categoriesList') + .then(function(data){ + $scope.categories=data.data; + console.log($scope.categories); + }, function(data){ + console.log('data error'); + console.log(data); + $ionicLoading.show({ template: 'Error connecting server', noBackdrop: true, duration: 2000 }); + + }); + $scope.categorySelected = function(){ + $scope.event.categories=[]; + for(var i=0; i<$scope.categories.length; i++) + { + if($scope.categories[i].selected) + { + $scope.event.categories.push($scope.categories[i]); + } + } + console.log($scope.event.categories); + }; + + $scope.postEvent = function(){ $http({ url: urlapi + 'events', diff --git a/www/templates/newEvent.html b/www/templates/newEvent.html index 56c6b01..0cbec73 100644 --- a/www/templates/newEvent.html +++ b/www/templates/newEvent.html @@ -15,17 +15,16 @@ {{'Hour' | translate}} - + + + Categories: + + {{category.name}} + +