Skip to content

Instantly share code, notes, and snippets.

@Robinyo
Last active August 29, 2015 14:26
Show Gist options
  • Save Robinyo/315023b5cf1fe0c385ad to your computer and use it in GitHub Desktop.
Save Robinyo/315023b5cf1fe0c385ad to your computer and use it in GitHub Desktop.
'use strict';
/*
* Dependency Injection Syntax and AngularJS
* The notation that we have used is one of the two ways in which we can declare AngularJS controllers
* (or services, directives, or filters). The style we have used, which is also the recommended way,
* is the safe-style of Dependency Injection, or declaration.
*/
angular.module('vardyger')
.controller('AppController', ['$log', '$scope', '$ionicModal', '$translate', 'AuthenticationService',
function(
$log, // inject the $log service
$scope, // inject the $scope service
$ionicModal, // inject the $ionicModal service
$translate, // inject the $translate service
AuthenticationService // inject the AuthenticationService service
) {
$log.info('AppController');
$scope.switchLanguage = function(key) {
$log.info('switchLanguage() to ' + key);
$translate.use(key);
};
$ionicModal.fromTemplateUrl('templates/login-template.html', {
scope: $scope,
animation: 'slide-in-up',
focusFirstInput: true
}).then(function(modal) {
$scope.loginModal = modal;
});
$scope.isLoggedIn = function() {
return AuthenticationService.isLoggedIn();
};
$scope.logout = function() {
AuthenticationService.logout();
};
$scope.$on('$destroy', function() {
$scope.loginModal.remove();
});
}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment