Guest User

controller

a guest
Apr 18th, 2016
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. angular.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. });
Add Comment
Please, Sign In to add comment