Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow usage without forRoot #372

Open
naveedahmed1 opened this issue Oct 21, 2019 · 3 comments
Open

Allow usage without forRoot #372

naveedahmed1 opened this issue Oct 21, 2019 · 3 comments

Comments

@naveedahmed1
Copy link

The current docs states that we should add AdsenseModule.forRoot to the app module, as a result, this plugin becomes part of the main bundle.

What if we are using it in just 1-2 sections of the website and don't want it to be a part of main bundle. Currently we still have to add it to app module.

It would be great to allow usage without adding it to app module and without forRoot.

Can this use case be supported?

@scttcper
Copy link
Owner

I think you could. Might need to make a provider for the injection token? https://github.com/scttcper/ng2-adsense/blob/master/src/lib/adsense.component.ts#L67

@naveedahmed1
Copy link
Author

Can you please provide some more details about how to do this?

@Ideki
Copy link

Ideki commented Aug 12, 2020

You could also use a shared module

import { NgModule } from '@angular/core';

import { AdsenseModule } from 'ng2-adsense';

@NgModule({
  declarations: [
  ],
  imports: [
    AdsenseModule.forRoot({
      adClient: 'yourNumberHere'
    })
  ],
  exports: [
    AdsenseModule
  ]
})
export class SharedModule { }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants