Created
August 18, 2016 17:23
-
-
Save brianpetro/cfeb0a97d2919e0885e814f40c5f704f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var app = angular.module('myApp', []); | |
app.controller('accountsSummaryCtrl', function ($scope) { | |
$scope.accounts = [{ | |
name: 'Assets', | |
balance: 4324.00, | |
subAccounts: [{ | |
name: 'Bank Account', | |
balance: 2000 | |
}, { | |
name: 'Cash', | |
balance: 2324.00 | |
}] | |
}, { | |
name: 'Receivables', | |
balance: 132.00, | |
subAccounts: [{ | |
name: 'Customer A', | |
balance: 32.00 | |
}, { | |
name: 'Customer B', | |
balance: 100.00 | |
}] | |
}, { | |
name: 'Debts', | |
balance: 0, | |
subAccounts: [{ | |
name: 'Collector A', | |
balance: 50 | |
}, { | |
name: 'Supplier B', | |
balance: -50.00 | |
}] | |
}, { | |
name: 'Equity', | |
balance: 4459, | |
subAccounts: [{ | |
name: 'Bank Account', | |
balance: 3000 | |
}, { | |
name: 'Customer C', | |
balance: 1459 | |
}] | |
}]; | |
}); | |
app.directive('account', function () { | |
return { | |
restrict: 'E', | |
scope: { | |
account: '=name' | |
}, | |
template: $('#account-template').html(), | |
controller: function ($scope, $element, $attrs) { | |
$scope.subAccountsOpen = false; | |
$scope.toggleSubAccounts = function () { | |
$scope.subAccountsOpen = !$scope.subAccountsOpen; | |
} | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment