[Fixed] TypeScript – passing a data type of interface in the constructor error


I am planning to pass a value in the constructor parameter that is type of Interface which is IDictation. But I get this error :

Uncaught Error: Can’t resolve all parameters for DictationComponent: (?).

I assume that typescript compiler couldn’t recognize the interface. Though I imported it.


import { Component, OnInit } from '@angular/core';
import {IDictation} from './IDictation';

  selector: 'app-dictation',
  templateUrl: './dictation.component.html',
  styleUrls: ['./dictation.component.sass'],

export class DictationComponent implements OnInit {

  private usrLvl : IDictation;    
  constructor( usrLvl : IDictation) 





Since you don’t instantiate a component directly, rather Angular does, you can only use the constructor parameters to pass in services via dependency injection.

What are you trying to accomplish? You can use the private variable and your interface without defining it as a constructor function parameter.

Leave a Reply

(*) Required, Your email will not be published