小编Efr*_* A.的帖子

尽管有数据源,mat-table angular 6 没有显示任何数据

我想通过 Angular material design 的数据表 mat-table 显示一个列表。这是我的组件:

import { LeaveapplicationService } from './../../services/leaveapplication.service';
import { leaveapplication } from './../../models/leaveapplication';
import { Component, OnInit, ViewChild, Input } from '@angular/core';
import { MatTableDataSource, MatPaginator, MatSort } from '@angular/material';
// import { DataSource } from '@angular/cdk/table';

@Component({
  selector: 'app-leaveapplication-list',
  templateUrl: './leaveapplication-list.component.html',
  styleUrls: ['./leaveapplication-list.component.scss']
})
export class LeaveapplicationListComponent implements OnInit {
  leaveApplications: leaveapplication[];
  displayedColumns: ['id', 'applicant', 'manager', 'leavetype', 'start', 'end', 'return', 'status'];
  dataSource: MatTableDataSource<leaveapplication>;

  constructor(private leaveApplicationService: LeaveapplicationService) { }

  @ViewChild(MatPaginator) paginator: MatPaginator;
  @ViewChild(MatSort) sort: …
Run Code Online (Sandbox Code Playgroud)

datatable typescript material-design angular

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

具有可扩展行的 Angular (7+) 材料表 - 同时多个扩展行

我正在使用带有可扩展行的材料表

我想在行单击时展开多行。默认行为是在单击新行时关闭先前展开的行。我不想关闭前面的那些,每个都应该保持打开状态,直到再次单击。我怎样才能做到这一点?

angular-material angular angular-material-table

4
推荐指数
1
解决办法
7873
查看次数

Angular 9 找不到类型为“object”的不同支持对象“[object Object]”。NgFor 只支持绑定到 Iterables,比如 Arrays

我在模板中为 Observable 使用异步管道:

applicants$: Observable<UserProfile[]>;
  ngOnInit() {
    this.applicants$ = this.store.pipe(
      select(fromRootUserProfileState.getUserProfiles)
    ) as Observable<UserProfile[]>;
}
Run Code Online (Sandbox Code Playgroud)

这是 UserProfile.ts 界面:

import { Role } from './role/role';
import { Country } from './Country';

export interface UserProfile {
  id?: number;
  fullName?: string;
  roles?: Role[];
  windowsAccount?: string;
  firstName?: string;
  lastName?: string;
  email?: string;
  managerName?: string;
  managerId?: number;
  managerEmail?: string;
  companyId?: number;
  companyName?: string;
  countryId?: number;
  country?: Country;
  countryName?: string;
}
Run Code Online (Sandbox Code Playgroud)

这是 userProfile.service

  getUserProfiles(): Observable<UserProfile[]> {
    return this.http.get<UserProfile[]>(
      this.baseUrl + 'userprofiles/getuserprofiles'
    );
  }
Run Code Online (Sandbox Code Playgroud)

在模板中,我使用 ngFor 通过异步管道遍历 …

javascript arrays observable typescript-typings angular

4
推荐指数
1
解决办法
8568
查看次数