Upgrade routing to Angular2.
This commit is contained in:
@ -4,6 +4,7 @@ import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { HttpClientModule } from '@angular/common/http';
|
||||
import { RouterModule } from '@angular/router';
|
||||
|
||||
import { NgLoggerModule, Level } from '@nsalaun/ng-logger';
|
||||
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
|
||||
@ -16,16 +17,16 @@ import { ScheduleEditModalComponent } from './scheduleEditModal.component';
|
||||
import { ScheduleFormComponent } from './scheduleForm.component';
|
||||
import { ScheduleRowComponent } from './scheduleRow.component';
|
||||
import { ScheduleListComponent } from './scheduleList.component';
|
||||
|
||||
export function accountIdServiceFactory(i: any) {
|
||||
return i.get('accountIdService');
|
||||
}
|
||||
import { ScheduleListState } from './schedule.states';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
HttpClientModule,
|
||||
CommonModule,
|
||||
FormsModule,
|
||||
RouterModule.forChild([
|
||||
ScheduleListState
|
||||
]),
|
||||
NgLoggerModule,
|
||||
ToastrModule,
|
||||
NgbModule,
|
||||
@ -33,11 +34,6 @@ export function accountIdServiceFactory(i: any) {
|
||||
],
|
||||
providers: [
|
||||
ScheduleService,
|
||||
{
|
||||
provide: 'accountIdService',
|
||||
deps: ['$injector'],
|
||||
useFactory: accountIdServiceFactory
|
||||
}
|
||||
],
|
||||
declarations: [
|
||||
ScheduleDeleteModalComponent,
|
||||
|
@ -1,7 +1,8 @@
|
||||
// vim: set tw=80 ts=2 sw=2 sts=2 :
|
||||
|
||||
import { ScheduleListComponent } from './scheduleList.component';
|
||||
|
||||
export const ScheduleListState = {
|
||||
name: 'scheduler',
|
||||
url: '/account/:accountId/scheduler',
|
||||
component: 'scheduleListComponent',
|
||||
path: 'account/:accountId/scheduler',
|
||||
component: ScheduleListComponent,
|
||||
}
|
||||
|
@ -1,4 +1,6 @@
|
||||
import { Component, Inject, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
|
||||
import { Observable } from 'rxjs/Rx';
|
||||
|
||||
import { Logger } from '@nsalaun/ng-logger';
|
||||
@ -53,7 +55,7 @@ export class ScheduleListComponent implements OnInit {
|
||||
private scheduleService: ScheduleService,
|
||||
private logger: Logger,
|
||||
private ngbModal: NgbModal,
|
||||
@Inject('accountIdService') private accountIdService
|
||||
private route: ActivatedRoute,
|
||||
) {}
|
||||
|
||||
$onInit() {
|
||||
@ -62,7 +64,7 @@ export class ScheduleListComponent implements OnInit {
|
||||
|
||||
ngOnInit() {
|
||||
this.logger.log("ngOnInit");
|
||||
this.accountId = this.accountIdService.get();
|
||||
this.accountId = +this.route.snapshot.paramMap.get('accountId')
|
||||
// Load operations on controller initialization.
|
||||
this.load();
|
||||
}
|
||||
|
Reference in New Issue
Block a user