daniel-nagy / md-data-table

Material Design Data Table for Angular Material
MIT License
1.9k stars 520 forks source link

mdOnSelect calling a function multiple times #592

Closed marcioeric closed 7 years ago

marcioeric commented 7 years ago

When I create a table and set it to call a callback function when an item is selected and reload the page, even with NO item selected it invokes the function several times until the window hangs. image image image

ArvindNikam76 commented 7 years ago

did you get solution for this

marcioeric commented 7 years ago

@ArvindNikam76 Yes, in my partial view I had this:

<tbody md-body>
    <tr md-row md-select="flow" md-select-id="flow.id" md-auto-select md-on-select="onSelectItem()" ng-repeat="flow in flows">
        <td md-cell>{{flow.step}}</td>
        <td md-cell>{{flow.desc}}</td>
        <td md-cell flex>
            <md-button ng-if="editItem" class="md-fab md-primary md-mini" aria-label="Profile" ng-click="editItem($event, flow)">
                <md-icon md-font-set="material-icons">create</md-icon>
            </md-button>
            <md-button ng-if="removeItem" class="md-fab md-warn md-mini" aria-label="Profile" ng-click="removeItem($event, flow, mainList)">
                <md-icon md-font-set="material-icons">delete_forever</md-icon>
            </md-button>
        </td>
    </tr>
</tbody>

I have the md-on-select () method, but it should only be passed the method name, ie:
md-on-select = "onSelectItem" no md-on-select = "onSelectItem ()"

ottort-23 commented 6 years ago

Thanks for the solution! this is i was looking for days.

ArvindNikam76 commented 6 years ago

@marcio-eric Thanks for solution.