0

After the git merge with my friend changes, our project in angular2 stopped to work:

It compiles properly but If I try to navigate inside my component, It doesn't get rendered and I get this message in the console:

Error: Uncaught (in promise): TypeError: name.match(...) is null

The component before the merge was properly rendered.

After lot of time spent in investigation, we notice that the problem comes from the constructor of the component and the services it uses.

This is the constructor that cause problems:

constructor(
    private mdService: MasterDataService,
    private _WebDBService: WebDBService,    
    private fb: FormBuilder,
    private loaderService: LoaderService,
    private _offlineOrderService: OfflineOrderService
  ) {
....
 }

If we remove the declaration of WebDbService and OfflineOrderService the component loads properly...

This is the working constructor:

constructor(
    private mdService: MasterDataService,
    //private _WebDBService: WebDBService,    
    private fb: FormBuilder,
    private loaderService: LoaderService,
    //private _offlineOrderService: OfflineOrderService
  ) {
....
 }

The two service are properly declared in app.module , we have checked... It should works...

We don't know what to check now.

Thanks to support

Vega
  • 27,856
  • 27
  • 95
  • 103
DarioN1
  • 2,460
  • 7
  • 32
  • 67
  • 1
    make sure these new service are provice in module – Aniruddha Das Oct 17 '17 at 15:36
  • 1
    This might be happening because the `WebDBService` is being export improperly (perhaps circular dependency?). Also, if the `WebDBService` is importing other services, try to import directly from the file if they are coming out of a barrel and it can resolve an error like this. That worked for me before. For instance, `import { Foo } from './services/foo';` instead of `import { Foo } from 'services';` – Lansana Camara Oct 17 '17 at 15:36
  • Lansana, what you mean for circular dependency ? May be that there are some "nested" dependency between the components... May be the problem is this – DarioN1 Oct 17 '17 at 15:42
  • 1
    @DarioN1 Yes, precisely. A circular dependency is when you have item A that injects item B, and item B injects item C. Item C also injects item A, though, which means the loop starts again and you get a circular loop. Look at this question for detailed answers on this issue: https://stackoverflow.com/questions/36378751/angular2-2-services-depending-on-each-other – Lansana Camara Oct 17 '17 at 15:49

0 Answers0