diff --git a/accountant/frontend/static/js/accounts.js b/accountant/frontend/static/js/accounts.js index 3cef9fc..537419f 100644 --- a/accountant/frontend/static/js/accounts.js +++ b/accountant/frontend/static/js/accounts.js @@ -29,8 +29,8 @@ accountantApp .controller( "AccountController", [ - "$scope", "$rootScope", "$window", "Accounts", - function($scope, $rootScope, $window, Accounts) { + "$scope", "$rootScope", "$window", "$routeParams", "Accounts", + function($scope, $rootScope, $window, $routeParams, Accounts) { $scope.accountClass = function(account) { if(account == $scope.selectedAccount) { @@ -174,7 +174,15 @@ accountantApp // Reset selected account to the new instance corresponding to the old // one. - if($scope.selectedAccount) { + if($routeParams.accountId) { + // Find the new instance of the previously selected account. + angular.forEach($scope.accounts, function(account) { + if(account.id == $routeParams.accountId) { + // No need to emit accountSelectedEvent. + $scope.selectedAccount = account; + } + }); + } else if($scope.selectedAccount) { // Find the new instance of the previously selected account. angular.forEach($scope.accounts, function(account) { if(account.id == $scope.selectedAccount.id) {