Adblock detector for Angular 8+ applications
npm install ng-adblock-detectFirst, import the NgAdblockDetectModule to your module:
``typescript
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { NgAdblockDetectModule } from 'ng-adblock-detect';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppComponent } from './app';
@NgModule({
imports: [BrowserModule, NgAdblockDetectModule],
declarations: [AppComponent],
bootstrap: [AppComponent]
})
export class AppModule {}
platformBrowserDynamic().bootstrapModule(AppModule);
`
The adblockDetected callback will be invoked after the view has loaded:
`typescript
import { Component } from '@angular/core';
@Component({
selector: 'app',
template:
Adblock Detected:
})
export class AppComponent {
detected(isDetected: boolean) {
console.log( ${isDetected});`
}
}
By default, the adblockDetected callback is invoked after 1 second. This can be configured by passing in a timer parameter to the component (milliseconds):
```