Greetings, I am fairly new to the realm of Angular and have some background in AngualarJS (not very helpful here hahaha).
Currently, I am referring to this resource to implement a Service/State for a specific Module.
However, when attempting to use it within the same module, I encounter a circular dependency issue with the message:
Warning: Circular dependency detected
I'm puzzled about how to effectively utilize the providedIn
property to specify a Module if this error persists.
home-store.service.ts
import { Injectable } from '@angular/core';
import { HomeModule } from './home.module';
export interface IHomeState {
user?: any;
}
@Injectable({ providedIn: HomeModule }) // My intention is to confine this service to HomeModule
export class HomeStoreService {}
home-module.ts
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { HomeComponent } from './home.component';
@NgModule({
declarations: [HomeComponent],
imports: [CommonModule, RouterModule.forChild([])],
})
export class HomeModule {}
home-component.ts
import { Component } from '@angular/core';
import { HomeStoreService } from './home-store.service';
@Component({
selector: 'home',
templateUrl: './home.component.html',
styleUrls: ['./home.component.scss'],
})
export class HomeComponent {
constructor(private homeStore: HomeStoreService) {}
}
Thank you for your assistance in advance.