File

src/app/pages/assignments/assignments.page.ts

Implements

OnInit

Metadata

Index

Properties
Methods

Constructor

Public constructor(backendService: BackendService, store: Store<State>)
Parameters :
Name Type Optional
backendService BackendService No
store Store<State> No

Methods

Public ngOnInit
ngOnInit()
Returns : void

Properties

Public Readonly assignments
Type : Observable<Assignment[]>
Default value : this.store.select('assignments').pipe(map((assignments) => Object.values(assignments)))
import { Component, OnInit } from '@angular/core';
import { Store } from '@ngrx/store';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';

import { Assignment } from 'src/app/model/api/assignment';
import { BackendService } from 'src/app/services/backend.service';
import { State } from 'src/app/store/state';

@Component({
  selector: 'apollo-assignments',
  templateUrl: './assignments.page.html',
  styleUrls: ['./assignments.page.scss'],
})
export class AssignmentsPage implements OnInit {
  public readonly assignments: Observable<Assignment[]> = this.store.select('assignments').pipe(map((assignments) => Object.values(assignments)));

  public constructor(
    private readonly backendService: BackendService,
    private readonly store: Store<State>,
  ) {}

  public ngOnInit(): void {
    this.backendService.fetchAssignments();
  }
}
<div class="assignment-grid">
  <apollo-assignment-card *ngFor="let assignment of assignments | async" [assignment]="assignment" class="grid-item"></apollo-assignment-card>
</div>

./assignments.page.scss

:host {
  display: block;
}

.assignment-grid {
  display: flex;
  flex-direction: column;

  > *:not(:last-child) {
    margin-bottom: 1rem;
  }
}

@media screen and (min-width: 801px) {
  .assignment-grid {
    flex-direction: row;
    flex-wrap: wrap;

    > * {
      margin-right: 1rem;
      flex-grow: 1;
      max-width: 16rem;
    }
  }
}
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""