Hey there, I am fairly new to Angular and currently collaborating on a project with a team. We recently faced a merge conflict resolution issue that led to the application not displaying in my browser. The console showed an error message as follows:
Uncaught Error: Can't resolve all parameters for StationComponent: (?, [object Object], [object Object], [object Object], [object Object], [object Object], ?).
Upon analyzing the error, it appears that the unknown parameters (?) in the error align with the StationService and UserServices being imported into the StationComponent's Constructor. Despite both services having the @Injectable annotation and correct import paths (even verified by VSCode), this error persists. Any insights or assistance would be greatly appreciated.
Below is the code snippet for 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;
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()
);
}
}