From 0d0cb721d547d6fe68e09e27ad48ef7022af8b21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=80lex=20Magaz=20Gra=C3=A7a?= Date: Fri, 1 Sep 2017 17:28:19 +0200 Subject: [PATCH] Avoid getting a separate instance of ServerResponseService for each PageNotFoundComponent https://angular.io/guide/ngmodule-faq#should-i-add-other-providers-to-a-module-or-a-component --- src/app/pagenotfound/pagenotfound.component.ts | 1 - src/app/shared/shared.module.ts | 4 +++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/app/pagenotfound/pagenotfound.component.ts b/src/app/pagenotfound/pagenotfound.component.ts index 6f546e9c2e..762a4000a1 100644 --- a/src/app/pagenotfound/pagenotfound.component.ts +++ b/src/app/pagenotfound/pagenotfound.component.ts @@ -5,7 +5,6 @@ import { Component, ChangeDetectionStrategy } from '@angular/core'; selector: 'ds-pagenotfound', styleUrls: ['./pagenotfound.component.scss'], templateUrl: './pagenotfound.component.html', - providers: [ServerResponseService], changeDetection: ChangeDetectionStrategy.OnPush }) export class PageNotFoundComponent { diff --git a/src/app/shared/shared.module.ts b/src/app/shared/shared.module.ts index d1699537b6..e94f40730e 100644 --- a/src/app/shared/shared.module.ts +++ b/src/app/shared/shared.module.ts @@ -24,6 +24,7 @@ import { ItemListElementComponent } from '../object-list/item-list-element/item- import { CommunityListElementComponent } from '../object-list/community-list-element/community-list-element.component'; import { CollectionListElementComponent } from '../object-list/collection-list-element/collection-list-element.component'; import { TruncatePipe } from './utils/truncate.pipe'; +import { ServerResponseService } from './server-response.service'; const MODULES = [ // Do NOT include UniversalModule, HttpModule, or JsonpModule here @@ -61,7 +62,8 @@ const COMPONENTS = [ const PROVIDERS = [ ApiService, HostWindowService, - { provide: NativeWindowService, useFactory: NativeWindowFactory } + { provide: NativeWindowService, useFactory: NativeWindowFactory }, + ServerResponseService ]; @NgModule({