Files
WinStudentGoalTracker/ui/winstudentgoaltracker/src/app/mobile/pages/students/students.ts
T
2026-03-02 14:08:01 -08:00

52 lines
1.5 KiB
TypeScript

import { Component, inject, signal } from '@angular/core';
import { StudentCard } from '../../components/student-card/student-card';
import { StudentService } from '../../../shared/services/dummy-student.service';
import { StudentCardDto } from '../../../shared/classes/student-card.dto';
@Component({
selector: 'app-students',
imports: [StudentCard],
templateUrl: './students.html',
styleUrl: './students.scss',
})
export class Students {
// ************************** Constructor **************************
constructor() {
this.loadStudents();
}
// ************************** Declarations *************************
private readonly studentService = inject(StudentService);
protected readonly students = signal<StudentCardDto[]>([]);
public errorMessage = signal<String | null>(null);
// ************************** Properties ***************************
// ************************ Public Methods *************************
// ************************ Event Handlers *************************
// ********************** Support Procedures ***********************
// *****************************************************************
// Loads the list of students assigned to the current user.
// *****************************************************************
private loadStudents() {
this.studentService.getDummyStudentsForUser().then(data => {
if (!data.success)
{
this.errorMessage.set(data.message);
}
else
{
this.students.set(data.payload || []);
}
});
}
}