我是 angular6 的新手,当我将参数从组件发送到服务时,我收到 StaticInjectorError。怎么了?
我的代码是这样的组件:
import { Component, Input, OnInit } from '@angular/core';
import { myService } from '../../@core/data/myService';
@Component({
selector: 'table',
templateUrl: './table.component.html'
})
export class TableComponent implements OnInit {
constructor(private service: myService) {
}
ngOnInit() {
this.service = new myService ("name");
}
Run Code Online (Sandbox Code Playgroud)
服务:
import { Injectable, Inject } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { DataService } from './data.service';
@Injectable() export class myService {
constructor(
entityName: string,
) {
console.log(entityName);
}
}
Run Code Online (Sandbox Code Playgroud)
app.module.ts:
import { …Run Code Online (Sandbox Code Playgroud) frontend dependency-injection web-frontend typescript angular6