;
(function () {
'use strict';
angular
.module('shuichan.app.controller', [])
.controller('AppController', AppController);
AppController.$inject = ['$state', '$ionicSideMenuDelegate', 'AuthenticationServiceConstant', 'AuthenticationService'];
/* @ngInject /
function AppController($state, $ionicSideMenuDelegate, AuthenticationServiceConstant, AuthenticationService) {
// jshint validthis: true
var vm = this;
vm.$state = $state;
vm.accessLevels = AuthenticationServiceConstant.accessLevels;
vm.loggingOut = false;
vm.doLogout = doLogout;
///////////////////////
function doLogout() {
vm.loggingOut = true;
AuthenticationService
.logout()
.then(
function (data) {
$ionicSideMenuDelegate.toggleLeft();
vm.$state.go('app.login');
}
)
.finally(
function () {
vm.loggingOut = false;
}
);
}
};
})();
John Papa的angular style guide上指view model的意思,具体解释可以看stackoverflow上John Papa的这个回答:http://stackoverflow.com/questions/16619740/angular-should-i-use-this-or-scope/19940503#19940503
this指向了这个变量vm,这里的this应该就是这个模块