javascript - angularjs中vm的意思
PHP中文网
PHP中文网 2017-04-10 17:29:06
0
2
626

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

}

};

})();

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(2)
迷茫

John Papa的angular style guide上指view model的意思,具体解释可以看stackoverflow上John Papa的这个回答:http://stackoverflow.com/questions/16619740/angular-should-i-use-this-or-scope/19940503#19940503

Ty80

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template