我正在学习 Angular 并通过AngularMaterial Course实际分析 Angular Material Paginator 。
实际上,mat-paginator
页面计数器基于课程的“静态”属性lessonsCount
:
<mat-paginator [length]="course?.lessonsCount"
“数据库”是:
export const COURSES: any = {
1: {
id: 1,
description: "Angular for Beginners",
iconUrl: 'https://angular-academy.s3.amazonaws.com/thumbnails/a.png',
courseListIcon: 'https://angular-academy.s3.amazonaws.com/main-logo/m.png',
longDescription: "Establish ...of Angular",
category: 'BEGINNER',
lessonsCount: 10
}
和
export const LESSONS = {
1: {
id: 1,
"description": "Angular Tutorial For Beginners - Bu...By Step",
"duration": "4:17",
"seqNo": 1,
courseId: 1
},
2: {
id: 2,
"description": "Building Your First Component - Component Composition",
"duration": "2:07",
"seqNo": 2,
courseId: 1
}
有没有办法从课程中删除“硬编码”lessonsCount
属性course
并使用基于来自数据库的课程数量的课程数量courseId
,而不是来自课程属性“课程数量”?