0

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.

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

  **/
}

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.