arnaucube
arnaucube/commonroutesServerPublic Self-hosted repository
commonroutesServer/app/www/js/controllers.js
app/www/js/controllers.jsRaw
 1angular.module('starter.controllers', [])
 2
 3.controller('AppCtrl', function($scope, $ionicModal, $timeout) {
 4
 5  // With the new view caching in Ionic, Controllers are only called
 6  // when they are recreated or on app start, instead of every page change.
 7  // To listen for when this page is active (for example, to refresh data),
 8  // listen for the $ionicView.enter event:
 9  //$scope.$on('$ionicView.enter', function(e) {
10  //});
11
12  // Form data for the login modal
13  $scope.loginData = {};
14
15  // Create the login modal that we will use later
16  $ionicModal.fromTemplateUrl('templates/login.html', {
17    scope: $scope
18  }).then(function(modal) {
19    $scope.modal = modal;
20  });
21
22  // Triggered in the login modal to close it
23  $scope.closeLogin = function() {
24    $scope.modal.hide();
25  };
26
27  // Open the login modal
28  $scope.login = function() {
29    $scope.modal.show();
30  };
31
32  // Perform the login action when the user submits the login form
33  $scope.doLogin = function() {
34    console.log('Doing login', $scope.loginData);
35
36    // Simulate a login delay. Remove this and replace with your login
37    // code if using a login system
38    $timeout(function() {
39      $scope.closeLogin();
40    }, 1000);
41  };
42})
43
44
45.controller('TravelsCtrl', function($scope, $http) {
46  /*$scope.travels = [
47    { id: 1, title: 'Travel1', description: "description for travel 1", owner: "user1", icon: "car" },
48    { id: 2, title: 'Travel2', description: "description for travel 2", owner: "user2", icon: "station-wagon" },
49    { id: 3, title: 'Travel3', description: "description for travel 3", owner: "user3", icon: "van" },
50    { id: 4, title: 'Travel4', description: "description for travel 4", owner: "user1", icon: "station-wagon" },
51    { id: 5, title: 'Travel5', description: "description for travel 5", owner: "user2", icon: "minivan" },
52    { id: 6, title: 'Travel6', description: "description for travel 6", owner: "user3", icon: "lorry" },
53    { id: 7, title: 'Travel7', description: "description for travel 7", owner: "user1", icon: "sport-car" },
54    { id: 8, title: 'Travel8', description: "description for travel 8", owner: "user2", icon: "jeep" }
55];*/
56    $scope.travels="";
57    $http.get('http://localhost:3000/api/travels')
58    .success(function(data, status, headers,config){
59      console.log('data success');
60      console.log(data); // for browser console
61      $scope.travels = data; // for UI
62    })
63    .error(function(data, status, headers,config){
64      console.log('data error');
65    })
66    .then(function(result){
67      travels = result.data;
68  });
69})
70.controller('TravelCtrl', function($scope, $stateParams) {
71    //$scope.travel=travels.get($stateParams.travelId);
72});