首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >错误TS2554:应为1个参数,但实际为0。Angular6

错误TS2554:应为1个参数,但实际为0。Angular6
EN

Stack Overflow用户
提问于 2018-09-06 03:08:51
回答 5查看 15.6K关注 0票数 8

我有这个问题,我的应用程序工作正常,但这个错误在IDE中显示。

employee.service.ts:

代码语言:javascript
运行
复制
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() { }
}

我的employeeDetail.ts文件是这样的:

代码语言:javascript
运行
复制
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();
  }

}

这是Employee-list.ts

代码语言:javascript
运行
复制
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();
  }

}

我该如何解决这个问题?真正的问题是什么?因为我是angular6的新手,所以我找不到这个错误,请解释一下。谢谢。

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52191925

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档