小编Ben*_*rke的帖子

备用行颜色角材料表

我想知道我如何定位内部的偶数/奇数行,Angular Material Table以便我可以将偶数/奇数行设置为不同的背景颜色.

我设置了我的ClaimFileHistoryDataSource课程:

claimClientInformation: ClaimFileHistory[];
dataSource : ClaimFileHistoryDataSource;
displayedColumns = ['TypeImg', 'Description', 'Agent'];


export class ClaimFileHistoryDataSource extends DataSource<ClaimFileHistory> {

    constructor(private _claimFileHistory: ClaimFileHistory[]) {
      super();
    }

    connect(): Observable<ClaimFileHistory[]> {
      return Observable.of(this._claimFileHistory);
    }

    disconnect() {}
}
Run Code Online (Sandbox Code Playgroud)

NgInit我打电话给我的服务去获取我需要的数据并填充DataSource:

this._claimFileHistoryService.getClaimFileHistoryById().subscribe(response => {
  this.claimClientInformation = response;       
  this.dataSource = new ClaimFileHistoryDataSource(this.claimClientInformation);
});
Run Code Online (Sandbox Code Playgroud)

这很好,数据正在回归.

在HTML中Mat-Table看起来像这样:

    <mat-table #table [dataSource]="dataSource">

      <ng-container matColumnDef="TypeImg">
        <mat-cell *matCellDef="let row"><img [src]='row.TypeImg' height="40px"></mat-cell>
      </ng-container>

      <ng-container matColumnDef="Description">
        <mat-cell *matCellDef="let row">
          <div>
            <span class="d-block">{{row.Description}}</span>
            <span class="d-block">{{row.Date}}</span> …
Run Code Online (Sandbox Code Playgroud)

html css angular-material2 angular

27
推荐指数
4
解决办法
3万
查看次数

RouterModule.forRoot调用了两次错误

我正在尝试将Lazy Loading实现到我的应用程序中,但似乎遇到了一个问题,我得到了错误消息:

// External Dependencies
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { HttpClientModule } from '@angular/common/http';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';

// Internal Dependencies
import { MaterialModule } from '../app/configuration/material/material.module';
import { SharedModule } from '../app/application/shared/shared.module';
import { RoutingModule } from '../app/configuration/routing/routing.module';
import { SettingsModule } from '../app/application/settings/settings.module';

import { AppComponent } from './app.component';

import { SearchService } from './application/shared/services/search.service';

@NgModule({
  declarations: [AppComponent],
  imports: [ …
Run Code Online (Sandbox Code Playgroud)

angular-routing angular

11
推荐指数
7
解决办法
1万
查看次数

标签 统计

angular ×2

angular-material2 ×1

angular-routing ×1

css ×1

html ×1