在我的项目中,我想使用服务中组件的方法。我想在AdminService中调用AdvisorComponent的ngOnInit()。服务是这样的:
import {AdminAdvisorListComponent} from "../components/admin-
components/admin-advosor-list/admin-advisor-list.component";
@Injectable()
export class AdminService {
public token: string;
public headers: any;
constructor(private http: Http,
private apiService: ApiService,
private adminAdvisorList: AdminAdvisorListComponent) {}
initializeAdvisorPage() {
this.adminAdvisorList.ngOnInit();
}
}
,AdminAdvisorListComponent代码为:
import {AdminService} from '../../../services/admin.service';
export class AdminAdvisorListComponent implements OnInit {
constructor(private adminService: AdminService){}
ngOnInit(): void {
this.adminService.getAdvisorList().subscribe(
res => {
if (res) {
this.users = res;
}
});
}
使用这些代码会出错
无法解析AdminAdvisorListComponent的所有参数:(?,[对象对象],[对象对象],[对象对象],[对象对象])。 我该怎么办? 感谢您提供高级帮助。