Clicking the next button on table pagination submits the form
I have a form element that wraps the table and some other content. Clicking the next button in the pagination submits the form. Submitting the form navigates to the next tab. The issue is that clicking the next button in pagination submits the form and navigates to the next tab. The expected behavior would be that it does not submit the form or take you to the next tab. This is due to md-button's default type="submit". The fix may be that you need to add type="button" to all pagination controls.
Please see the following (simplified) plunkr that reproduces the issue:
http://plnkr.co/edit/NXEZ3JIoSOuf8rRzBhap?p=preview
And related issue:
https://github.com/angular/material/issues/710
By the way, thanks for the great work on this project. It is the perfect solution until we get table support in angular material.
If anyone else encounters this issue, I ended up just copying the template and overriding it with type="button" in my code.
angular.module('templates.md-data-table-pagination.html', []).run(['$templateCache', function($templateCache) {
'use strict';
$templateCache.put('templates.md-data-table-pagination.html',
'<div>\n' +
' <span class="label">{{paginationLabel.text}}</span>\n' +
' <md-select ng-model="limit" md-container-class="md-pagination-select" ng-change="onSelect()" aria-label="Row Count" placeholder="{{rowSelect ? rowSelect[0] : 5}}">\n' +
' <md-option ng-repeat="rows in rowSelect ? rowSelect : [5, 10, 15]" ng-value="rows">{{rows}}</md-option>\n' +
' </md-select>\n' +
' <span>{{min()}} - {{max()}} {{paginationLabel.of}} {{total}}</span>\n' +
'</div>\n' +
'<div>\n' +
' <md-button type="button" ng-click="first()" ng-disabled="!hasPrevious()" aria-label="First">\n' +
' <md-icon md-svg-icon="templates.navigate-first.html"></md-icon>\n' +
' </md-button>\n' +
' <md-button type="button" ng-click="previous()" ng-disabled="!hasPrevious()" aria-label="Previous">\n' +
' <md-icon md-svg-icon="templates.navigate-before.html"></md-icon>\n' +
' </md-button>\n' +
' <md-button type="button" ng-click="next()" ng-disabled="!hasNext()" aria-label="Next">\n' +
' <md-icon md-svg-icon="templates.navigate-next.html"></md-icon>\n' +
' </md-button>\n' +
' <md-button type="button" ng-click="last()" ng-disabled="!hasNext()" aria-label="Last">\n' +
' <md-icon md-svg-icon="templates.navigate-last.html"></md-icon>\n' +
' </md-button>\n' +
'</div>\n' +
'');
}]);
Resolved in version 0.8.13. In the future if you find an easy fix like this feel free to make a pull request.