title: Mat-Table Selection only on current PageSize?
body: <p>I'm building a table with pagination that handles some actions based on an array of selected checkboxes; I've the <a href="https://material.angular.io/components/table/overview#selection" rel="noreferrer">docs</a> and as far a just selecting ALL rows of just a few individually everything's good;</p>
  
  <p>The scenario I'm trying to get to to work is the following: If my <code>PageSize</code> on my <code>paginator</code> is "10", and I click the <code>masterToggle</code> to select "all" rows, I want that to select all the rows on the current page, nothing more, so that would be the 10 rows that are being displayed with the current <code>PageSize</code>, however, this selects the whole <code>dataSource</code> of the table which is around 300 records.</p>
  
  <p>Is there a way to make the <code>masterToggle</code> select only the rows that are displayed based on the PageSize? Then If I change the <code>PageSize</code> to 20 only the first 10 would stay selected.</p>
  
  <p>This is my code.</p>
  
  <pre><code>/** Whether the number of selected elements matches the total number of rows. */
    isAllSelected() {
      const numSelected = this.selection.selected.length;
      const numRows = this.dataSource.data.length;
      return numSelected === numRows;
    }
  
    /** Selects all rows if they are not all selected; otherwise clear selection. */
    masterToggle() {
      this.isAllSelected() ?
          this.selection.clear() :
          this.dataSource.data.forEach(row =&gt; this.selection.select(row));
    }
  </code></pre>