i have this problem, my app working fine but this error shows in IDE.
employee.service.ts :
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class EmployeeService {
getEmployee(){
return [
{"id":1,"name":"Micheal","age":21},
{"id":2,"name":"Jackson","age":22},
{"id":3,"name":"Hales","age":23},
{"id":4,"name":"Moz","age":25}
];
}
constructor() { }
}
and my employeeDetail.ts file is this:
import { Component, OnInit } from '@angular/core';
import { EmployeeService } from '../services/employee.service';
@Component({
selector: 'employee-detail',
templateUrl: './employee-detail.component.html',
styleUrls: ['./employee-detail.component.css']
})
export class EmployeeDetailComponent implements OnInit {
public employees = [];
constructor(private _employeeService : EmployeeService) {
}
ngOnInit() {
this.employees = this._employeeService.getEmployee();
}
}
Here is the Employee-list.ts
import { Component, OnInit } from '@angular/core';
import {HttpClientModule} from '@angular/common/http';
import { EmployeeService } from '../services/employee.service';
@Component({
selector: 'employee-list',
templateUrl: './employee-list.component.html',
styleUrls: ['./employee-list.component.css']
})
export class EmployeeListComponent implements OnInit {
public employees = []
constructor(private _employeeService : EmployeeService) {
}
ngOnInit() {
this.employees = this._employeeService.getEmployee();
}
}
how can I solve this problem? what is the actual problem? as I am new to angular6 so I cannot figure out the error, please explain this. Thank you.
I do not see any issue with your code, as i see you should stop the applicaiton with Ctrl + C
and then do ng serve
Anyhow the reason being is that, your getEmployee method still needs one parameter to be passed, just make sure your code is saved on the service part.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With