(function () { 'use strict'; angular .module('app') .controller('UserChangePasswordController', userChangePassword); function userChangePassword($scope, $state, userRepository, errorHandler, uiNotifications, $translate, localizationHelper) { var vm = this; vm.translationObject = {}; vm.loadTranslation = function(){ $translate(['Info', 'PasswordWasChanged']).then(function (tr) { vm.translationObject = tr; }); }; vm.unsubscribe = localizationHelper.eventEmitter.subscribe('onLanguageChangedEvent', function (lang) { vm.loadTranslation(); }); vm.loadTranslation(); // Variables. vm.profile = { "password": null, "confirmPassword": null }; vm.currentProfileId = $state.params.id; vm.isVisible = false; //Methods. vm.changePassword = function(){ userRepository.changePassword(vm.profile, vm.currentProfileId).success(function(response, status, headers, config){ if (errorHandler.check(response, status, config) == errorHandler.STATUS.SUCCESS) { uiNotifications.inform(vm.translationObject['PasswordWasChanged'], 'info'); } }); }; setTimeout(function(){ vm.profile.password = ""; vm.isVisible = true; }, 100); $scope.$on("$destroy", function(){ vm.unsubscribe(); }); } // IoC container. userChangePassword.$inject = [ "$scope", '$state', "repository.user", "appUtils.errorHandler", "appUtils.uiNotifications", "$translate", "helpers.localization" ]; })();