TwoToc code
[YouAndWeb_TwoToc] / client / app / main / main.controller.js
diff --git a/client/app/main/main.controller.js b/client/app/main/main.controller.js
new file mode 100755 (executable)
index 0000000..d8187e0
--- /dev/null
@@ -0,0 +1,37 @@
+'use strict';
+
+angular.module('dashboardApp')
+  .controller('MainCtrl', function($scope, $http, $state) {
+
+    $scope.slides = [
+      {
+        image: 'soccer-ball.jpg',
+        text: 'PARTECIPA, ORGANIZZA, GUARDA, SOCIALIZZA'
+      },
+      {
+        image: 'got.jpg',
+        text: 'DAJE, SU, MEH, AHO'
+      }
+    ];
+
+    $scope.search = {};
+    $scope.getLocation = function(val) {
+      return $http.get('//maps.googleapis.com/maps/api/geocode/json', {
+        params: {
+          address: val,
+          sensor: false
+        }
+      }).then(function(response){
+        return response.data.results.map(function(item){
+          $scope.search.lat = (item.geometry.viewport.northeast.lat + item.geometry.viewport.southwest.lat) / 2;
+          $scope.search.lng = (item.geometry.viewport.northeast.lng + item.geometry.viewport.southwest.lng) / 2;
+          return item.formatted_address;
+        });
+      });
+    };
+
+    $scope.searchShow = function() {
+      console.log($scope.search);
+      $state.go('partecipa', {lat: $scope.search.lat, lng: $scope.search.lng});
+    };
+  });