I tried to inject AccountService in the LoginService but it won\'t ,the accountService is undefined but in the other hand the authServiceProvider is defined .
Contraril
You should always provide your service in the root injector unless there is a case where you want the service to be available only if the consumer imports a particular @NgModule.
try to add your service you want to inject in providers : [ ]
in your core.module
import { NgModule, LOCALE_ID } from '@angular/core';
import { DatePipe, registerLocaleData } from '@angular/common';
import { HttpClientModule } from '@angular/common/http';
import { Title } from '@angular/platform-browser';
import locale from '@angular/common/locales/en';
@NgModule({
imports: [HttpClientModule],
exports: [],
declarations: [],
providers: [
AccountService,
Title,
{
provide: LOCALE_ID,
useValue: 'en'
},
DatePipe
]
})
export class CoreModule {
constructor() {
registerLocaleData(locale);
}
}
and in your AccountService replace @Injectable({ providedIn: 'root' })
with @Injectable()
@Injectable()
export class AccountService {
private userIdentity: any;
private authenticated = false;
private authenticationState = new Subject();
constructor(private languageService: JhiLanguageService, private sessionStorage: SessionStorageService, private http: HttpClient) {}