選択オプションが angular 6 mat-paginator に表示されない理由を特定するために、ご協力をお願いします。また、戻るボタンと次へボタンのスタイルを設定する方法。
私は以下の例に従おうとしています:
https://stackblitz.com/angular/anvplbamrbj?file=app%2Ftable-pagination-example.html
上記の例では、mat-paginator から mat-option をクリックすると、テーブルの上に選択オプションが表示されます。この例をプロジェクトにコピーすると、mat-paginator からの選択オプションがテーブルの下に表示されます。なぜそれが起こるのかわかりません。
印刷画面でわかるように、mat-paginator は機能していますが、「ページごとの itens」オプションをクリックすると、選択オプションが非表示になります (選択オプションは、Web ページから要素を検査するときにのみ表示されます。
この問題は何らかの CSS ファイルにあると思いますが、修正方法がわかりません。
以下の私のコードに従ってください:
list-devices.component.html: stackblitz.com から例をコピーして貼り付けるだけです
<div class="mat-elevation-z8">
<table mat-table [dataSource]="dataSource">
<!-- Position Column -->
<ng-container matColumnDef="position">
<th mat-header-cell *matHeaderCellDef> No. </th>
<td mat-cell *matCellDef="let element"> {{element.position}} </td>
</ng-container>
<!-- Name Column -->
<ng-container matColumnDef="name">
<th mat-header-cell *matHeaderCellDef> Name </th>
<td mat-cell *matCellDef="let element"> {{element.name}} </td>
</ng-container>
<!-- Weight Column -->
<ng-container matColumnDef="weight">
<th mat-header-cell *matHeaderCellDef> Weight </th>
<td mat-cell *matCellDef="let element"> {{element.weight}} </td>
</ng-container>
<!-- Symbol Column -->
<ng-container matColumnDef="symbol">
<th mat-header-cell *matHeaderCellDef> Symbol </th>
<td mat-cell *matCellDef="let element"> {{element.symbol}} </td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
</table>
<mat-paginator [pageSizeOptions]="[5, 10, 20]" showFirstLastButtons></mat-paginator>
</div>
.ts ファイル
import { Component, OnInit, ViewChild} from '@angular/core';
import {MatPaginator, MatTableDataSource} from '@angular/material';
/**
* Controller for list devices view
*
* @export
* @class ListDevicesComponent
* @implements {OnInit}
*/
@Component({
selector: 'app-list-device-home',
templateUrl: './list-devices.component.html',
styleUrls: ['./list-devices.component.scss']
})
export class ListDevicesComponent implements OnInit {
displayedColumns: string[] = ['position', 'name', 'weight', 'symbol'];
dataSource = new MatTableDataSource<PeriodicElement>(ELEMENT_DATA);
@ViewChild(MatPaginator) paginator: MatPaginator;
ngOnInit() {
this.dataSource.paginator = this.paginator;
}
}
export interface PeriodicElement {
name: string;
position: number;
weight: number;
symbol: string;
}
const ELEMENT_DATA: PeriodicElement[] = [
{position: 1, name: 'Hydrogen', weight: 1.0079, symbol: 'H'},
{position: 2, name: 'Helium', weight: 4.0026, symbol: 'He'},
{position: 3, name: 'Lithium', weight: 6.941, symbol: 'Li'},
{position: 4, name: 'Beryllium', weight: 9.0122, symbol: 'Be'},
{position: 5, name: 'Boron', weight: 10.811, symbol: 'B'},
{position: 6, name: 'Carbon', weight: 12.0107, symbol: 'C'},
{position: 7, name: 'Nitrogen', weight: 14.0067, symbol: 'N'},
{position: 8, name: 'Oxygen', weight: 15.9994, symbol: 'O'},
{position: 9, name: 'Fluorine', weight: 18.9984, symbol: 'F'},
{position: 10, name: 'Neon', weight: 20.1797, symbol: 'Ne'},
{position: 11, name: 'Sodium', weight: 22.9897, symbol: 'Na'},
{position: 12, name: 'Magnesium', weight: 24.305, symbol: 'Mg'},
{position: 13, name: 'Aluminum', weight: 26.9815, symbol: 'Al'},
{position: 14, name: 'Silicon', weight: 28.0855, symbol: 'Si'},
{position: 15, name: 'Phosphorus', weight: 30.9738, symbol: 'P'},
{position: 16, name: 'Sulfur', weight: 32.065, symbol: 'S'},
{position: 17, name: 'Chlorine', weight: 35.453, symbol: 'Cl'},
{position: 18, name: 'Argon', weight: 39.948, symbol: 'Ar'},
{position: 19, name: 'Potassium', weight: 39.0983, symbol: 'K'},
{position: 20, name: 'Calcium', weight: 40.078, symbol: 'Ca'},
];
list-devices.component.scss
@import '~@angular/material/prebuilt-themes/deeppurple-amber.css';
.label{
border-radius: 4px;
font-size: 75%;
padding: 4px 7px;
margin-right: 5px;
font-weight: 400;
color: #fff !important;
}
.mat-paginator-navigation-first {
background: #11c15b;
}
.label-success{
border-radius: 4px;
font-size: 75%;
padding: 4px 7px;
margin-right: 5px;
font-weight: 400;
color: #fff !important;
background: #11c15b;
}
.label-warning{
border-radius: 4px;
font-size: 75%;
padding: 4px 7px;
margin-right: 5px;
font-weight: 400;
color: #fff !important;
background: #e5e500;
}
.label-danger{
border-radius: 4px;
font-size: 75%;
padding: 4px 7px;
margin-right: 5px;
font-weight: 400;
color: #fff !important;
background: #ff5252;
}
.roow {
display: flex;
overflow-x: scroll;
}
.mat-table {
width: 100%;
}
.td-style {
font-family: "Roboto", sans-serif;
font-size: 1.1em;
color: #455a64;
}
.th-style {
font-family: "Roboto", sans-serif;
font-size: 1em;
font-weight: bold;
color: #455a64;
}
.table-title-style {
margin: 20px;
margin-top: 5px;
margin-bottom: 0px;
color: #37474f;
font-weight: 500;
position: relative;
position: sticky;
font-size: 15px;
top: 0;
}
.mat-header-row {
position: sticky;
top: 0;
background-color: #fff;
}
.body {
font-family: Roboto, Arial, sans-serif;
margin: 0;
}
.basic-container {
padding: 30px;
}
.version-info {
font-size: 8pt;
float: right;
}
/** No CSS for this example */
::ng-deep .mat-select-content{
background-color: red;
font-size: 1.5em;
}
table {
width: 100%;
}