Fix selected account.
This commit is contained in:
parent
c66e164c8d
commit
89b8c7925a
@ -29,8 +29,8 @@ accountantApp
|
|||||||
|
|
||||||
.controller(
|
.controller(
|
||||||
"AccountController", [
|
"AccountController", [
|
||||||
"$scope", "$rootScope", "$window", "Accounts",
|
"$scope", "$rootScope", "$window", "$routeParams", "Accounts",
|
||||||
function($scope, $rootScope, $window, Accounts) {
|
function($scope, $rootScope, $window, $routeParams, Accounts) {
|
||||||
|
|
||||||
$scope.accountClass = function(account) {
|
$scope.accountClass = function(account) {
|
||||||
if(account == $scope.selectedAccount) {
|
if(account == $scope.selectedAccount) {
|
||||||
@ -174,7 +174,15 @@ accountantApp
|
|||||||
|
|
||||||
// Reset selected account to the new instance corresponding to the old
|
// Reset selected account to the new instance corresponding to the old
|
||||||
// one.
|
// 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.
|
// Find the new instance of the previously selected account.
|
||||||
angular.forEach($scope.accounts, function(account) {
|
angular.forEach($scope.accounts, function(account) {
|
||||||
if(account.id == $scope.selectedAccount.id) {
|
if(account.id == $scope.selectedAccount.id) {
|
||||||
|
Loading…
Reference in New Issue
Block a user