不能将命名空间用作类型 angular

Cannot use namespace as a type angular

我有一项服务无法正常工作,但它与另一项确实有效的服务非常相似。它只是给我错误:

Cannot use namespace 'FeatureService' as a type.

我在 windows 上使用 angular 6 和 ngrx。

这是我的效果文件,给我带来了麻烦。这很奇怪,因为我有另一个类似的服务 CoreService,但没有给我这个问题。而且它们几乎完全相同。好吧,它们基于其他模块,我不确定这是否会有所不同。

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
  ) {}

}

这是我的服务文件:

@Injectable()
export class FeatureService {
  constructor(private httpClient: HttpClient) {}

  retrieveProfileData(profileId: number): Observable<any> {
    return this.httpClient
        .get(SERVER_URL_STAGING2 + profileId);
  }
}

有什么帮助吗?

我刚刚找到了解决方案。 因为我已经有了在模块核心上运行的服务,所以我创建了一个新文件夹以在其中添加每个服务,然后我从核心添加了工作服务。我还向其中添加了 feature.service.ts,然后将这些文件添加到模块核心上的 index.ts。

所以,现在我有了这些。

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
  ) {}
}

使用以下 index.ts 文件:

export * from './services/core.services'
export * from './services/features.services'

最后我有以下文件结构:

|-- app     
     |-- core
       |-- [+] authentication
       |-- services
           |-- core.ts  
           |-- features.ts  
       |-- core.module.ts  
       |-- index.ts  
     |-- features
       |-- profile
           |-- profile.efects.ts  

希望对大家有所帮助。