Hey everyone, I've recently embarked on my Angular learning journey.
Unfortunately, I'm currently facing this Error:
32 this.warning.error.push(entry.name+': '+entry.error);
~~~~~
src/app/dashboard/dashboard.component.ts:33:15 - error TS2339: Property 'id' does not exist on type 'Warning[]'.
33 this.warning.id.push(entry.id);
~~
src/app/dashboard/dashboard.component.ts:37:13 - error TS2339: Property 'error' does not exist on type 'Error[]'.
37 this.error.error.push(entry.name+': '+entry.error);
~~~~~
src/app/dashboard/dashboard.component.ts:38:13 - error TS2339: Property 'id' does not exist on type 'Error[]'.
38 this.error.id.push(entry.id);
~~
The issue lies in the fact that I have defined Interfaces for both of them and have imported them as well.
export interface Error {
id: number;
error: string;
}
export interface Warning {
id: number;
error: string;
}
You can see how they are implemented in my component below.
import { Error, Warning } from '../dashboard';
...
export class DashboardComponent implements OnInit {
error: Error[];
warning: Warning[];
...
evaluate(): void{
for (let entry of this.status){
if (entry.status === 0){
this.ok = this.ok + 1;
}
if (entry.status === 1 && entry.value < 8){
this.warnings = this.warnings + 1;
this.warning.error.push(entry.name+': '+entry.error);
this.warning.id.push(entry.wt_id);
}
if (entry.status === 1 && entry.value >= 8){
this.critical = this.critical + 1;
this.error.error.push(entry.wt_name+': '+entry.error);
this.error.id.push(entry.wt_id);
}
}
}
I have tried various methods mentioned in previous posts but to no avail.
If any of you have a solution or spot a mistake, I would greatly appreciate your input. Maybe it's just something small that slipped my notice.
Cheers!