I've got a service that I cannot make it work but it is very similar to another service that DOES work. It just give me the error:
Cannot use namespace 'FeatureService' as a type.
I'm using angular 6 and ngrx on windows.
This is my effects file, that is giving me trouble. Its strange because I've got another similar service CoreService
that does not give me that problem. And they are almost identical. Well, they are based in other modules, I'm not sure if that can make the difference.
import { FeatureService } from '../feature.services';
import { CoreService } from '../../core/core.services';
@Injectable()
export class ProfileEffects {
constructor(
private actions$: Actions<Action>,
private localStorageService: LocalStorageService,
private service: FeatureService,
private service2: CoreService
) {}
}
And this is my service file:
@Injectable()
export class FeatureService {
constructor(private httpClient: HttpClient) {}
retrieveProfileData(profileId: number): Observable<any> {
return this.httpClient
.get(SERVER_URL_STAGING2 + profileId);
}
}
Any help?
I've just found a solution. Since I already had the services working on the module core, I've created a new folder to add every service there, then I added the working service from core. Also I added my feature.service.ts to it, and then add those files to my index.ts on module core.
So, now i have these.
import { FeatureService } from '@app/core';
import { CoreService } from '@app/core';
@Injectable()
export class ProfileEffects {
constructor(
private actions$: Actions<Action>,
private localStorageService: LocalStorageService,
private service: FeatureService,
private service2: CoreService
) {}
}
with the following index.ts file:
export * from './services/core.services'
export * from './services/features.services'
At the end I have the following file structure:
|-- app
|-- core
|-- [+] authentication
|-- services
|-- core.ts
|-- features.ts
|-- core.module.ts
|-- index.ts
|-- features
|-- profile
|-- profile.efects.ts
I hope it helps someone.