let fooListTemplate = `
<ul>
<li ng-repeat="foo in $ctrl.foos">
{{foo.name}}: {{ foo.cost }}
</li>
</ul>
Total cost: {{ $ctrl.total }}
`;
function FooListController() {
let sum = (acc, val) => acc + val;
this.total = this.foos.reduce(sum, 0);
}
// Register the component declaration
module.component("fooList", {
template: fooListTemplate.html,
controller: FooController,
bindings: { foos: '<' }
});
----------------------------------------
<!-- Use the component -->
<foo-list foos="$ctrl.data.foos"></foo-list>