Html 单击行将角度材质涟漪效果添加到Mat表
我使用的是角材料v6。我想在单击我的Html 单击行将角度材质涟漪效果添加到Mat表,html,angular,sass,angular-material,material-design,Html,Angular,Sass,Angular Material,Material Design,我使用的是角材料v6。我想在单击我的mat表中的一行时添加连锁反应 HTML: <table mat-table [dataSource]="this.projectsList" class="mat-elevation-z8"> <ng-container matColumnDef="id"> <th mat-header-cell *matHeaderCellDef>ID</th> <td mat-cell *mat
mat表中的一行时添加连锁反应
HTML:
<table mat-table [dataSource]="this.projectsList" class="mat-elevation-z8">
<ng-container matColumnDef="id">
<th mat-header-cell *matHeaderCellDef>ID</th>
<td mat-cell *matCellDef="let project">{{project.id}}</td>
</ng-container>
<ng-container matColumnDef="title">
<th mat-header-cell *matHeaderCellDef>Title</th>
<td mat-cell *matCellDef="let project">{{project.title}}</td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="this.displayColumns"></tr>
<tr mat-row *matRowDef="let row; columns: this.displayColumns"></tr>
</table>
table {
width: 90vw;
margin-top: 1%;
margin-left: auto;
margin-right: auto;
}
.mat-row:hover {
background: rgba(0, 0, 0, 0.04);
}
AppRoutingModule,
BrowserModule,
BrowserAnimationsModule,
MatToolbarModule,
MatSidenavModule,
MatButtonModule,
MatCheckboxModule
@import '~@angular/material/theming';
@import './palette.scss';
// Plus imports for other components in your app.
// Include the common styles for Angular Material. We include this here so that you only
// have to load a single css file for Angular Material in your app.
// **Be sure that you only ever include this mixin once!**
@include mat-core();
// Define the default theme (same as the example above).
$light-primary-blue: mat-palette($primary-blue);
$light-accent-purple: mat-palette($accent-purple);
$light-theme: mat-light-theme($light-primary-blue, $light-accent-purple);
// Include the default theme styles.
@include angular-material-theme($light-theme);
// Define an alternate dark theme.
$dark-primary: mat-palette($primary-blue);
$dark-accent: mat-palette($accent-purple);
$dark-theme: mat-dark-theme($dark-primary, $dark-accent);
// Include the alternative theme styles inside of a block with a CSS class. You can make this
// CSS class whatever you want. In this example, any component inside of an element with
// `.dark` will be affected by this alternate dark theme instead of the default theme.
.dark {
@include angular-material-theme($dark-theme);
}
模块导入:
<table mat-table [dataSource]="this.projectsList" class="mat-elevation-z8">
<ng-container matColumnDef="id">
<th mat-header-cell *matHeaderCellDef>ID</th>
<td mat-cell *matCellDef="let project">{{project.id}}</td>
</ng-container>
<ng-container matColumnDef="title">
<th mat-header-cell *matHeaderCellDef>Title</th>
<td mat-cell *matCellDef="let project">{{project.title}}</td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="this.displayColumns"></tr>
<tr mat-row *matRowDef="let row; columns: this.displayColumns"></tr>
</table>
table {
width: 90vw;
margin-top: 1%;
margin-left: auto;
margin-right: auto;
}
.mat-row:hover {
background: rgba(0, 0, 0, 0.04);
}
AppRoutingModule,
BrowserModule,
BrowserAnimationsModule,
MatToolbarModule,
MatSidenavModule,
MatButtonModule,
MatCheckboxModule
@import '~@angular/material/theming';
@import './palette.scss';
// Plus imports for other components in your app.
// Include the common styles for Angular Material. We include this here so that you only
// have to load a single css file for Angular Material in your app.
// **Be sure that you only ever include this mixin once!**
@include mat-core();
// Define the default theme (same as the example above).
$light-primary-blue: mat-palette($primary-blue);
$light-accent-purple: mat-palette($accent-purple);
$light-theme: mat-light-theme($light-primary-blue, $light-accent-purple);
// Include the default theme styles.
@include angular-material-theme($light-theme);
// Define an alternate dark theme.
$dark-primary: mat-palette($primary-blue);
$dark-accent: mat-palette($accent-purple);
$dark-theme: mat-dark-theme($dark-primary, $dark-accent);
// Include the alternative theme styles inside of a block with a CSS class. You can make this
// CSS class whatever you want. In this example, any component inside of an element with
// `.dark` will be affected by this alternate dark theme instead of the default theme.
.dark {
@include angular-material-theme($dark-theme);
}
自定义主题:
<table mat-table [dataSource]="this.projectsList" class="mat-elevation-z8">
<ng-container matColumnDef="id">
<th mat-header-cell *matHeaderCellDef>ID</th>
<td mat-cell *matCellDef="let project">{{project.id}}</td>
</ng-container>
<ng-container matColumnDef="title">
<th mat-header-cell *matHeaderCellDef>Title</th>
<td mat-cell *matCellDef="let project">{{project.title}}</td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="this.displayColumns"></tr>
<tr mat-row *matRowDef="let row; columns: this.displayColumns"></tr>
</table>
table {
width: 90vw;
margin-top: 1%;
margin-left: auto;
margin-right: auto;
}
.mat-row:hover {
background: rgba(0, 0, 0, 0.04);
}
AppRoutingModule,
BrowserModule,
BrowserAnimationsModule,
MatToolbarModule,
MatSidenavModule,
MatButtonModule,
MatCheckboxModule
@import '~@angular/material/theming';
@import './palette.scss';
// Plus imports for other components in your app.
// Include the common styles for Angular Material. We include this here so that you only
// have to load a single css file for Angular Material in your app.
// **Be sure that you only ever include this mixin once!**
@include mat-core();
// Define the default theme (same as the example above).
$light-primary-blue: mat-palette($primary-blue);
$light-accent-purple: mat-palette($accent-purple);
$light-theme: mat-light-theme($light-primary-blue, $light-accent-purple);
// Include the default theme styles.
@include angular-material-theme($light-theme);
// Define an alternate dark theme.
$dark-primary: mat-palette($primary-blue);
$dark-accent: mat-palette($accent-purple);
$dark-theme: mat-dark-theme($dark-primary, $dark-accent);
// Include the alternative theme styles inside of a block with a CSS class. You can make this
// CSS class whatever you want. In this example, any component inside of an element with
// `.dark` will be affected by this alternate dark theme instead of the default theme.
.dark {
@include angular-material-theme($dark-theme);
}
我找不到任何关于向表中添加涟漪效应的文档,但我看到了几个Stackblitz实例,它们在行单击时具有涟漪效应。我试图复制他们正在做的事情,但没有成功。修改td元素,如下所示
<table mat-table [dataSource]="this.projectsList" class="mat-elevation-z8">
<ng-container matColumnDef="title">
<th mat-header-cell *matHeaderCellDef>Title</th>
<td mat-cell *matCellDef="let project">
<div class='mat-ripple-wrapper' matRipple>
{{project.title}}
</div>
</td>
</ng-container>
</table>
mat-ripple指令会在单击触发器元素后创建一个div,如果将其放置在一行上,则会使其失去位置。通过将td数据包装到一个div中,并在该div上添加指令以包含动态生成的div,我可以最好地让它工作