controllers.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. angular.module('starter.controllers', ['starter.services'])
  2. .controller('AppCtrl', function($scope, $ionicModal, $timeout) {
  3. // Form data for the login modal
  4. $scope.loginData = {};
  5. // Create the login modal that we will use later
  6. $ionicModal.fromTemplateUrl('templates/login.html', {
  7. scope: $scope
  8. }).then(function(modal) {
  9. $scope.modal = modal;
  10. });
  11. // Triggered in the login modal to close it
  12. $scope.closeLogin = function() {
  13. $scope.modal.hide();
  14. };
  15. // Open the login modal
  16. $scope.login = function() {
  17. $scope.modal.show();
  18. };
  19. // Perform the login action when the user submits the login form
  20. $scope.doLogin = function() {
  21. console.log('Doing login', $scope.loginData);
  22. // Simulate a login delay. Remove this and replace with your login
  23. // code if using a login system
  24. $timeout(function() {
  25. $scope.closeLogin();
  26. }, 1000);
  27. };
  28. })
  29. .controller('SessionsCtrl', function($scope, Session) {
  30. $scope.sessions = Session.query();
  31. })
  32. .controller('SessionCtrl', function($scope, $stateParams, Session) {
  33. $scope.session = Session.get({sessionId: $stateParams.sessionId});
  34. });