Whenever I attempt to compile the project for production, an error pops up:
There is a problem resolving all parameters for EmployeeComponent in C:/.../src/app/employee/employee.component.ts: (?, ?, ?).
Oddly enough, when I run the application, everything functions correctly without any errors.
The EmployeeComponent
code snippet appears as follows:
import { Component, OnInit } from '@angular/core';
import { Score } from '../score/score';
@Component({
selector: 'app-employee',
templateUrl: './employee.component.html',
styleUrls: ['./employee.component.css']
})
export class EmployeeComponent implements OnInit {
name: string;
employeeId: number;
totalScore: number;
scores: Score[] = new Array<Score>();
public constructor(name: string, employeeId: number, scores: number[]) {
this.name = name;
this.employeeId = employeeId;
this.totalScore = 0;
for(let i = 0; i < 5; i++) {
this.scores[i] = new Score(scores[i], i);
this.totalScore += scores[i];
}
}
ngOnInit() {
}
setTotalScore() {
this.totalScore = 0;
for(let score of this.scores) {
this.totalScore += Number(score.value);
}
}
}
The EmployeeComponent
contains a variable called scores
which has a Type of Score
, defined as shown below:
export class Score {
value: number;
id: number;
constructor(value: number, id: number) {
this.value = value;
this.id = id;
}
}
I am creating the employees like this:
import { EmployeeComponent } from './employee/employee.component';
export var mockEmployees: EmployeeComponent[] = [
new EmployeeComponent("Lorem Ipsum 1", 1, [10, 20, 30, 40, 50]),
new EmployeeComponent("Lorem Ipsum 2", 2, [11, 21, 31, 41, 51]),
(add more EmployeeComponent instances as needed)
];
Any advice on why this error is occurring?