so I'm trying to make a crud application without bootstrap or an API. I have a json I want to be able to read, delete and update from but I cant get my application to just display my pseudo assignments in my json it has no errors but my table isn't populating here is my components typescript
import { AfterViewInit, Component, ViewChild } from '@angular/core';
import { MatTableModule, MatTable } from '@angular/material/table';
import { MatPaginatorModule, MatPaginator } from '@angular/material/paginator';
import { AssignmentsService } from '../assignments.service';
import { AssignmentI } from '../assignment-i';
import { HttpClientModule } from '@angular/common/http';
import { Observable } from 'rxjs';
@Component({
selector: 'app-assignment-table',
templateUrl: './assignment-table.component.html',
styleUrls: ['./assignment-table.component.css'],
standalone: true,
imports: [MatTableModule, MatPaginatorModule, HttpClientModule],
providers: [AssignmentsService]
})
export class AssignmentTableComponent implements AfterViewInit {
@ViewChild(MatPaginator) paginator!: MatPaginator;
@ViewChild(MatTable) table!: MatTable<AssignmentI>;
displayedColumns: string[] = ['assignment_name', 'class', 'type', 'due_date'];
dataSource: AssignmentI[] = [];
constructor(private assignmentsService: AssignmentsService) {}
ngAfterViewInit(): void {
this.assignmentsService.getAssignment()
.subscribe(assignments => {
this.dataSource = assignments;
});
}
}```
this is my service as well
import { Injectable, inject } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable, of } from 'rxjs';
import { AssignmentI } from './assignment-i';
@Injectable({
providedIn: 'root',
})
export class AssignmentsService {
private http = inject(HttpClient);
public getAssignment(): Observable<AssignmentI[]> {
return this.http.get<AssignmentI[]>('assets/assignments.json');
}
}