Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Why do I see the method executed many times?
Message
 
 
To
All
General information
Forum:
Javascript
Category:
Other
Title:
Why do I see the method executed many times?
Miscellaneous
Thread ID:
01620290
Message ID:
01620290
Views:
43
Hi everybody,

I am wondering why do I see the getFilteredTotal method executed many times (I removed the breakpoint eventually) for this simple piece of code:
<div class="col-md-11 col-md-offset-1">
            <div class="row">
                <table  id="transactionsList" ng-show="invoiceTransactionsObject.transactions.length>0"
                       class="table table-bordered table-hover table-list">
                    <thead>
                        <tr>
                            <td>Trans No</td>
                            <td>@Labels.quantity</td>
                            <td>@Labels.message</td>
                            <td>@Labels.item</td>
                            <td>@Labels.amount</td>
                            <td>@Labels.CreatedBy</td>
                            <td>@Labels.CreatedOn</td>
                        </tr>
                    </thead>
                    <tbody>
                        <tr ng-repeat="trans in filteredTransactions = (invoiceTransactionsObject.transactions | filter:searchTerm | filter: dateRangeFilter)">
                            <td>{{trans.transNo}}</td>
                            <td>{{trans.quantity}}</td>
                            <td>{{trans.message}}</td>
                            <td>{{trans.item}}</td>
                            <td><span ng-class="{'negative-amount' : trans.extension < 0}">{{trans.extension | currency}}</span></td>
                            <td>{{trans.operator}}</td>
                            <td>{{trans.dateTime | date: 'MM-dd-yyyy'}}</td>
                        </tr>
                    </tbody>
                    <tfoot>
                        <tr>
                            <td colspan="4">@String.Format(Labels.totalX, Labels.amount)</td>
                            <td class="col-md-3"><span ng-class="{'negative-amount': filteredTotal < 0}">{{getFilteredTotal('extension')|currency}}</span></td>
                        </tr>
                    </tfoot>
                </table>
I put the breakpoint in the getFilteredTotal method and I can see it executed several times (when I got tired I removed the breakpoint). I think I've seen similar issues before.

Why would angularJs JavaScript execute this code multiple times when it's in a table? It is not in the ng-repeat directive, right? As the tr tag is closed already.

BTW, it seems to be working nicely applying both filters and totaling filtered list.
If it's not broken, fix it until it is.


My Blog
Next
Reply
Map
View

Click here to load this message in the networking platform