我计划在构造函数参数中传递一个值,即接口类型,即IDictation。但我知道这个错误:
未明错误:无法解析DictationComponent:(?)的所有参数。
我假设类型记录编译器无法识别接口。虽然是我进口的。
Dictation.Component.ts
import { Component, OnInit } from '@angular/core';
import {IDictation} from './IDictation';
@Component({
selector: 'app-dictation',
templateUrl: './dictation.component.html',
styleUrls: ['./dictation.component.sass'],
})
export class DictationComponent implements OnInit {
private usrLvl : IDictation;
constructor( usrLvl : IDictation)
{}
/**
code
**/
}发布于 2017-04-20 19:17:00
由于不直接实例化组件,而只实例化组件,所以只能使用构造函数参数通过依赖项注入传递服务。
你想做什么?您可以使用私有变量和接口,而无需将其定义为构造函数参数。
https://stackoverflow.com/questions/43527794
复制相似问题