angularjs中vm的意思

;
(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;
    }
  );

}

};

})();

阅读 7.6k
2 个回答

this指向了这个变量vm,这里的this应该就是这个模块

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题