You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
2.6 KiB

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