@angular/common/http#HttpClientXsrfModule TypeScript Examples

The following examples show how to use @angular/common/http#HttpClientXsrfModule. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: core.module.ts    From budget-angular with GNU General Public License v3.0 6 votes vote down vote up
@NgModule({
  imports: [
    HttpClientModule,
    HttpClientXsrfModule.withOptions({
      cookieName: "XSRF-Token",
      headerName: "XSRF-Token",
    }),
    ...modules,
    BrowserAnimationsModule,
    MatProgressBarModule,
    SharedModule,
    RouterModule,
    MatNativeDateModule,
  ],
  declarations: [LayoutComponent, MenuItemDirective],
  providers: [
    CacheService,
    ConfigProvider,
    HttpErrorHandler,
    {
      provide: HTTP_INTERCEPTORS,
      useClass: HttpErrorInterceptor,
      multi: true,
    },
  ],
  exports: [LayoutComponent],
})
export class CoreModule {}
Example #2
Source File: feature-search.module.ts    From geonetwork-ui with GNU General Public License v2.0 6 votes vote down vote up
@NgModule({
  declarations: [
    SortByComponent,
    ResultsLayoutComponent,
    FuzzySearchComponent,
    RecordsMetricsComponent,
    ResultsListContainerComponent,
    ResultsHitsContainerComponent,
    SearchStateContainerDirective,
  ],
  imports: [
    CommonModule,
    TranslateModule.forChild(),
    StoreModule.forFeature(SEARCH_FEATURE_KEY, reducer, {
      initialState,
    }),
    EffectsModule.forFeature([SearchEffects]),
    HttpClientModule,
    HttpClientXsrfModule,
    UiSearchModule,
    UiInputsModule,
    ApiModule,
    FacetsModule,
    InfiniteScrollModule,
  ],
  exports: [
    SortByComponent,
    ResultsLayoutComponent,
    FuzzySearchComponent,
    RecordsMetricsComponent,
    ResultsListContainerComponent,
    ResultsHitsContainerComponent,
    FacetsModule,
    SearchStateContainerDirective,
  ],
})
export class FeatureSearchModule {}
Example #3
Source File: app.module.ts    From rubic-app with GNU General Public License v3.0 5 votes vote down vote up
@NgModule({
  declarations: [AppComponent],
  imports: [
    CoreModule,
    SharedModule,
    TuiRootModule,
    TuiNotificationsModule,
    TuiDialogModule,
    HttpClientXsrfModule.withOptions({
      cookieName: 'csrftoken',
      headerName: 'X-CSRFToken'
    }),
    BrowserModule,
    BrowserAnimationsModule,
    AppRoutingModule,
    HttpClientModule,
    GoogleTagManagerModule.forRoot({
      id: 'GTM-PZ8NH4J'
    })
  ],
  bootstrap: [AppComponent]
})
export class AppModule {
  constructor(
    private readonly router: Router,
    private readonly viewportScroller: ViewportScroller
  ) {
    this.setScrollStrategy();
  }

  /**
   * Defines scroll strategy, when page url is changed.
   * Doesn't scroll if only query parameters are changed.
   */
  private setScrollStrategy(): void {
    this.router.events
      .pipe(
        filter((e: Event): e is Scroll => e instanceof Scroll),
        pairwise()
      )
      .subscribe(([prevEvent, event]) => {
        if (event.position) {
          // backward navigation
          this.viewportScroller.scrollToPosition(event.position);
        } else if (event.anchor) {
          // anchor navigation
          this.viewportScroller.scrollToAnchor(event.anchor);
        } else if (
          prevEvent.routerEvent.urlAfterRedirects.split('?')[0] !==
          event.routerEvent.urlAfterRedirects.split('?')[0]
        ) {
          // forward navigation
          this.viewportScroller.scrollToPosition([0, 0]);
        }
      });
  }
}