在 addTo.component.ts 组件中,我有一个方法和构造函数,如下所示
Method:
**addTo(ServicePlanId, basketSection) {......}**
Constructor:
**constructor(
private route: ActivatedRoute,
private router: Router,
private addToService: addToService,
private DashboardService: DashboardService) { })**
Imports:
import { Component, OnInit, Input, Output, EventEmitter,AfterViewInit} from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';
import {addToService} from './../services/addTo.service';
import {DashboardService} from './../../roles/services/dashboard.service';
现在我尝试在另一个名为dashboard.component的组件中调用addTo方法,如下所示
imports of dashboard.component.ts
import {Router, ActivatedRoute} from '@angular/router';
import {DashboardService} from './../services/dashboard.service';
import {addToService} from './../../addToCart/services/addTo.service';
当我尝试为 addTo.component.ts 创建对象时,会抛出下面的异常
**[0] app/modules/roles/components/dashboard.component.ts(87,33): error TS2345: Argument of type 'typeof ActivatedRoute' is not assignable to parameter of type 'ActivatedRoute'.
[0] Property 'url' is missing in type 'typeof ActivatedRoute'.**
**export class DashboardRole implements AfterViewInit {
......
......
addToComp = new addToComponent(ActivatedRoute, Router, addToService, DashboardService);
}**
任何人建议我如何解决此错误,如果我的代码有任何问题,请建议我。