File
Implements
Metadata
selector |
app-transports |
styleUrls |
transports-page.component.scss |
templateUrl |
./transports-page.component.html |
Constructor
constructor(store: Store)
|
|
Methods
onViewChanged
|
onViewChanged(newViewType: string)
|
|
|
onViewDateChanged
|
onViewDateChanged(change: string)
|
|
|
allCalendarViews
|
allCalendarViews: Observable<Array>
|
Type : Observable<Array>
|
|
import { Component, OnInit } from '@angular/core';
import * as fromTransports from '../../reducers'
import { Store } from '@ngrx/store';
import { Observable } from 'rxjs/Observable';
import { CalendarOptions } from '../../models/calendar-options';
import { ChangeCalendarViewAction, ChangeViewDateAction } from '../../actions/calendar.actions';
@Component({
selector: 'app-transports',
templateUrl: './transports-page.component.html',
styleUrls: ['./transports-page.component.scss']
})
export class TransportsPageComponent implements OnInit {
async: any;
calendarOptions: Observable<CalendarOptions>;
allCalendarViews: Observable<Array<string>>;
constructor(private store: Store<fromTransports.State>) { }
ngOnInit() {
this.calendarOptions = this.store.select(fromTransports.getCalendarOptions);
this.allCalendarViews = this.store.select(fromTransports.getAllCalendarViews);
this.store.dispatch(new ChangeViewDateAction('today'));
}
onViewDateChanged(change: string): void {
this.store.dispatch(new ChangeViewDateAction(change));
}
onViewChanged(newViewType: string): void {
this.store.dispatch(new ChangeCalendarViewAction(newViewType));
}
}
<app-view-header [viewList]="allCalendarViews | async"
(viewChanged)="onViewChanged($event)">
</app-view-header>
<app-calendar [title]="(calendarOptions | async).title"
[subTitle]="(calendarOptions | async).subTitle"
[ngSwitch]="(calendarOptions | async).viewType"
(viewDateChanged)="onViewDateChanged($event)">
<mwl-calendar-day-view *ngSwitchCase="'day'"
[viewDate]="(calendarOptions | async).viewDate">
</mwl-calendar-day-view>
<mwl-calendar-week-view *ngSwitchCase="'week'"
[viewDate]="(calendarOptions | async).viewDate">
</mwl-calendar-week-view>
<mwl-calendar-month-view *ngSwitchCase="'month'"
[viewDate]="(calendarOptions | async).viewDate">
</mwl-calendar-month-view>
</app-calendar>
Legend
Html element with directive