toSignal via Gemini
This commit is contained in:
@@ -1,31 +1,22 @@
|
||||
import { Component, OnInit, inject } from '@angular/core';
|
||||
import { Component, inject, computed } from '@angular/core';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatTableModule } from '@angular/material/table';
|
||||
import { ActivatedRoute, RouterLink } from '@angular/router';
|
||||
|
||||
import { Role } from '../role';
|
||||
import { RoleListDataSource } from './role-list-datasource';
|
||||
|
||||
import { RoleService } from '../role.service';
|
||||
@Component({
|
||||
selector: 'app-role-list',
|
||||
templateUrl: './role-list.component.html',
|
||||
styleUrls: ['./role-list.component.css'],
|
||||
imports: [MatButtonModule, MatIconModule, MatTableModule, RouterLink],
|
||||
})
|
||||
export class RoleListComponent implements OnInit {
|
||||
export class RoleListComponent {
|
||||
private roleService = inject(RoleService);
|
||||
private route = inject(ActivatedRoute);
|
||||
listResource = this.roleService.list();
|
||||
|
||||
list: Role[] = [];
|
||||
dataSource: RoleListDataSource = new RoleListDataSource(this.list);
|
||||
dataSource = computed(() => this.listResource.value() ?? []);
|
||||
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
|
||||
displayedColumns = ['name', 'includedRoles', 'permissions'];
|
||||
|
||||
ngOnInit() {
|
||||
this.route.data.subscribe((value) => {
|
||||
const data = value as { list: Role[] };
|
||||
this.list = data.list;
|
||||
});
|
||||
this.dataSource = new RoleListDataSource(this.list);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user