I have an array that holds x number stocks in a JSON format and I am having a user enter the amount of shares they hold for each stock. My application will display the user's held value (valuePerShare * shares
) for each stock.
<ul>
<li ng-repeat="x in stocks">
{{ x.symbol + ', ' + x.valuePerShare }}
<p>Enter number of shares owned : <input type="text" ng-model="shares"></p>
<p ng-if='shares'>{{shares}} shares. Value total: {{(x.valuePerShare*shares)}} </p>
</li>
<li> Summary: </li>
<li> {{ stocks.length + ' stocks in portfolio' }} </li>
</ul>
How can I give a "portfolio total" in the summary that sums up x.valuePerShare*shares
for all x stocks? Is there someway to grab that reactive value outside of the ng-repeat
?