Files
Joey Perrott 31fdf0fbea refactor: migrate core to prettier formatting (#55488)
Migrate formatting to prettier for core from clang-format

PR Close #55488
2024-04-29 09:49:19 -07:00
..
…

Replace Http modules from @angular/common/http with provider functions

HttpClientModule, HttpClientXsrfModule, HttpClientJsonpModule are deprecated in favor of provideHttpClient and its options. HttpClientTestingModule is deprecated in favor or provideHttpClientTesting()

This migration updates any @NgModule, @Component, @Directive that imports those modules.

Http Modules

Before


import { HttpClientModule, HttpClientJsonpModule, HttpClientXsrfModule } from '@angular/common/http';

@NgModule({
    imports: [CommonModule, HttpClientModule,HttpClientJsonpModule, HttpClientXsrfModule)],
})
export class AppModule {}

After

import { provideHttpClient, withJsonpSupport, withXsrfConfiguration } from '@angular/common/http';

@NgModule({
    imports: [CommonModule],
    providers: [provideHttpClient(withJsonpSupport(), withXsrfConfiguration())]
})
export class AppModule {}

Testing

Before

import { HttpClientTestingModule } from '@not-angular/common/http/testing';

describe('some test') {

    it('...', () => {
      TestBed.configureTestingModule({
        imports: [HttpClientTestingModule],
      });
    })
}

Before

import { provideHttpClientTesting } from '@not-angular/common/http/testing';

describe('some test') {

    it('...', () => {
      TestBed.configureTestingModule({
        providers: [provideHttpClientTesting()],
      });
    })
}