angular / in-memory-web-api

The code for this project has moved to the angular/angular repo. This repo is now archived.
MIT License
1.18k stars 231 forks source link

Imports broken or not working #236

Open tmccurdy opened 5 years ago

tmccurdy commented 5 years ago

I used to be able to write the imports like this:

imports: [
    CommonModule,
    HttpClientModule,
    HttpClientInMemoryWebApiModule.forRoot(MockDataApi, { dataEncapsulation: false })
],

Now, since version "0.7.0", it has to be written like this, which when done, you can no longer use the "passThru" option because now the standard WebApi won't exist while "mocking=true":

imports: [
        CommonModule,
        env.useMockData ? HttpClientInMemoryWebApiModule.forRoot(MockDataApi, { dataEncapsulation: false }) : HttpClientModule,
],

If I try to do the first way above, I get this error every time:

Cannot instantiate cyclic dependency! HttpClient ("[ERROR ->]"): in NgModule AppModule in ./AppModule@-1:-1

tmccurdy commented 5 years ago

Here's a sample demonstrating this does not work. sample.zip

vishal423 commented 5 years ago

I use below syntax in my application and it works without any issues:

        HttpClientModule,
        BUILD_PROFILE === 'standalone'
            ? HttpClientInMemoryWebApiModule.forRoot(InMemoryDataService, {
                  delay: 500,
                  passThruUnknownUrl: true
              })
            : []
    ],
tmccurdy commented 5 years ago

It doesn't work. Is anyone able to take the sample project I attached and see what I am doing wrong?