Advertisement
Guest User

Untitled

a guest
Jun 19th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import {Component, ViewChild} from '@angular/core';
  2. import {MatPaginator, MatTableDataSource} from '@angular/material';
  3.  
  4. /**
  5.  * @title Table with pagination
  6.  */
  7. @Component({
  8.   selector: 'table-pagination-example',
  9.   styleUrls: ['table-pagination-example.css'],
  10.   templateUrl: 'table-pagination-example.html',
  11. })
  12. export class TablePaginationExample {
  13.   displayedColumns = ['position', 'name', 'weight', 'symbol'];
  14.   dataSource = new MatTableDataSource<Element>(ELEMENT_DATA);
  15.  
  16.   @ViewChild(MatPaginator) paginator: MatPaginator;
  17.  
  18.   /**
  19.    * Set the paginator after the view init since this component will
  20.    * be able to query its view for the initialized paginator.
  21.    */
  22.   ngAfterViewInit() {
  23.     this.dataSource.paginator = this.paginator;
  24.   }
  25. }
  26.  
  27. export interface Element {
  28.   name: string;
  29.   position: number;
  30.   weight: number;
  31.   symbol: string;
  32. }
  33.  
  34. const ELEMENT_DATA: Element[] = [
  35.   {position: 1, name: 'Hydrogen', weight: 1.0079, symbol: 'H'},
  36.   {position: 2, name: 'Helium', weight: 4.0026, symbol: 'He'},
  37.   {position: 3, name: 'Lithium', weight: 6.941, symbol: 'Li'},
  38.   {position: 4, name: 'Beryllium', weight: 9.0122, symbol: 'Be'},
  39.   {position: 5, name: 'Boron', weight: 10.811, symbol: 'B'},
  40.   {position: 6, name: 'Carbon', weight: 12.0107, symbol: 'C'},
  41.   {position: 7, name: 'Nitrogen', weight: 14.0067, symbol: 'N'},
  42.   {position: 8, name: 'Oxygen', weight: 15.9994, symbol: 'O'},
  43.   {position: 9, name: 'Fluorine', weight: 18.9984, symbol: 'F'},
  44.   {position: 10, name: 'Neon', weight: 20.1797, symbol: 'Ne'},
  45.   {position: 11, name: 'Sodium', weight: 22.9897, symbol: 'Na'},
  46.   {position: 12, name: 'Magnesium', weight: 24.305, symbol: 'Mg'},
  47.   {position: 13, name: 'Aluminum', weight: 26.9815, symbol: 'Al'},
  48.   {position: 14, name: 'Silicon', weight: 28.0855, symbol: 'Si'},
  49.   {position: 15, name: 'Phosphorus', weight: 30.9738, symbol: 'P'},
  50.   {position: 16, name: 'Sulfur', weight: 32.065, symbol: 'S'},
  51.   {position: 17, name: 'Chlorine', weight: 35.453, symbol: 'Cl'},
  52.   {position: 18, name: 'Argon', weight: 39.948, symbol: 'Ar'},
  53.   {position: 19, name: 'Potassium', weight: 39.0983, symbol: 'K'},
  54.   {position: 20, name: 'Calcium', weight: 40.078, symbol: 'Ca'},
  55. ];
  56.  
  57.  
  58. /**  Copyright 2017 Google Inc. All Rights Reserved.
  59.     Use of this source code is governed by an MIT-style license that
  60.     can be found in the LICENSE file at http://angular.io/license */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement