I'm really new to Angular, but I'm working on a project with a team. After resolving a merge conflict, the application stopped displaying in my browser, and the console displays this error:
Uncaught Error: Can't resolve all parameters for StationComponent: (?, [object Object], [object Object], [object Object], [object Object], [object Object], ?).
From the error, it looks like the StationComponent's Constructor, and the two (?)'s in the error align with the StationService, and UserServices that are being imported. I don't know why this error is being thrown. Both services have the @Injectable annotation, and their import paths are correct (I've even has VSCode re-import them automatically). Can someone help me?
Here's the Component's class:
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { Station } from '../../models/station';
import { Rail } from '../../models/rail';
import { StationService } from '../../services/station.service';
import { DragulaService } from 'ng2-dragula/components/dragula.provider';
import { UtilsService } from '../../services/utils.service';
import { DialogService, DialogComponent } from 'ng2-bootstrap-modal';
import { AddRailComponent } from '../add-rail/add-rail.component';
import { Subject } from 'rxjs/Subject';
import { ApplicationRef } from '@angular/core';
import { UserService } from '../../services/user.service';
@Component({
selector: 'app-station',
templateUrl: './station.component.html',
styleUrls: ['./station.component.css']
})
export class StationComponent implements OnInit {
public static refreshStation: Subject<boolean> = new Subject();
station: Station; // = new Station(268, 'Station Name', null, null, [126, 127, 128], null);
rails: Rail[] = [];
roleId: number;
constructor(
private stationService: StationService,
private route: ActivatedRoute,
private dragula: DragulaService,
private utilsService: UtilsService,
private dialogService: DialogService,
private appRef: ApplicationRef,
private userService: UserService) {
StationComponent.refreshStation.subscribe(
res => {
console.log('Refreshing...');
this.getStation();
this.getRails();
}
);
}
ngOnInit() {
this.getStation();
this.getRails();
this.roleId = this.userService.getUsersRole().id;
this.dragula.drop.subscribe(
val => {
this.station.railIds = this.utilsService.map(this.rails, e => e.railId);
this.stationService.saveRailOrder(this.station);
}
);
}
getStation() {
this.station = this.stationService.selected();
}
getRails() {
if (this.station != null) {
this.stationService.getRails(this.station)
.subscribe(
response => {
this.rails = response;
},
err => this.handleError(err)
);
}
}
handleError(err) {
console.log(err);
}
showAddRail() {
const disposable = this.dialogService.addDialog(AddRailComponent, { station: this.station}).subscribe(resp =>
this.stationService.refresh()
);
}
}