Angular_Beginner
Angular_Beginner

Reputation: 1

Angular extending class throwing can't resolve parameters error

I am new to angular and facing below issue while extending dashboard class with base class.

Please help whats wrong I am doing. I tried finding similar queries but was not able to find it.

PFA Code and Error image file.

// Base Component

export class BaseComponent implements OnInit {
  currentUrl: string;
  constructor(private route: Router) { }

  ngOnInit() {
    this.currentUrl = this.route.url;
    console.log(this.currentUrl);
  }

}


// main component

export class DashboardComponent extends BaseComponent implements OnInit {

  constructor(e) { 
    super(e);
  }

  ngOnInit() {
    console.log(this.currentUrl);
  }

}

Error

Upvotes: 0

Views: 36

Answers (1)

Leandro Lima
Leandro Lima

Reputation: 1164

The DashboardComponent are supposed to pass all parameters that BaseComponent needs. So you need to inject these parameters in the DashboardComponent.

export class DashboardComponent extends BaseComponent implements OnInit {

  constructor(route: Router) { 
    super(route);
  }

  ngOnInit() {
    console.log(this.currentUrl);
  }

}

Upvotes: 1

Related Questions