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
This commit is contained in:
Àlex Magaz Graça
2017-09-01 17:28:19 +02:00
parent 181c890473
commit 0d0cb721d5
2 changed files with 3 additions and 2 deletions

View File

@@ -5,7 +5,6 @@ import { Component, ChangeDetectionStrategy } from '@angular/core';
selector: 'ds-pagenotfound', selector: 'ds-pagenotfound',
styleUrls: ['./pagenotfound.component.scss'], styleUrls: ['./pagenotfound.component.scss'],
templateUrl: './pagenotfound.component.html', templateUrl: './pagenotfound.component.html',
providers: [ServerResponseService],
changeDetection: ChangeDetectionStrategy.OnPush changeDetection: ChangeDetectionStrategy.OnPush
}) })
export class PageNotFoundComponent { export class PageNotFoundComponent {

View File

@@ -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 { CommunityListElementComponent } from '../object-list/community-list-element/community-list-element.component';
import { CollectionListElementComponent } from '../object-list/collection-list-element/collection-list-element.component'; import { CollectionListElementComponent } from '../object-list/collection-list-element/collection-list-element.component';
import { TruncatePipe } from './utils/truncate.pipe'; import { TruncatePipe } from './utils/truncate.pipe';
import { ServerResponseService } from './server-response.service';
const MODULES = [ const MODULES = [
// Do NOT include UniversalModule, HttpModule, or JsonpModule here // Do NOT include UniversalModule, HttpModule, or JsonpModule here
@@ -61,7 +62,8 @@ const COMPONENTS = [
const PROVIDERS = [ const PROVIDERS = [
ApiService, ApiService,
HostWindowService, HostWindowService,
{ provide: NativeWindowService, useFactory: NativeWindowFactory } { provide: NativeWindowService, useFactory: NativeWindowFactory },
ServerResponseService
]; ];
@NgModule({ @NgModule({