lmeijdam / angular-umd-dynamic-example

Angular UMD example of loading new modules dynamically
174 stars 55 forks source link

shared service at module level #17

Open chesminsky opened 5 years ago

chesminsky commented 5 years ago

Hi. I m trying to implement dynamic loading using your technique. I got some problem. If my dynamic module has providers

@NgModule({
    providers: [
        SampleService
    ],
//....
})

and this service is injected in component i get NullInjectorError: No provider for SampleService! if i declare it as

@Component({
    providers: [
        SampleService
    ],
})

everything seems ok, but service get destroyed with component

I need help... How can i make shared service at module level ? PS my angular version is 5