Skip to content

Commit 5ec3002

Browse files
committed
feat(enviroment): added enviroment and service Title
1 parent c068595 commit 5ec3002

File tree

6 files changed

+23
-9
lines changed

6 files changed

+23
-9
lines changed

e2e/hero-create-new.e2e-spec.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import {AngularTOHPage} from './app.po';
2+
3+
describe('angular-hero-cli App', function () {
4+
let page: AngularTOHPage;
5+
6+
beforeEach(() => {
7+
page = new AngularTOHPage();
8+
});
9+
10+
it('Title', () => {
11+
page.navigateTo();
12+
expect(page.getParagraphText()).toEqual('Top Heroes');
13+
});
14+
});

src/app/app.component.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import {Component, Inject} from '@angular/core';
1+
import {Component} from '@angular/core';
2+
import {Title} from '@angular/platform-browser';
23

3-
import {APP_CONFIG} from './config/app.config';
4-
import {IAppConfig} from './config/iapp.config';
4+
import {environment} from '../environments/environment';
55

66
@Component({
77
selector: 'toh-app',
@@ -11,7 +11,7 @@ import {IAppConfig} from './config/iapp.config';
1111
export class AppComponent {
1212
title: string;
1313

14-
constructor(@Inject(APP_CONFIG) private appConfig: IAppConfig) {
15-
this.title = this.appConfig.title;
14+
constructor(private titleService: Title) {
15+
titleService.setTitle(environment.title);
1616
}
1717
}

src/app/config/app.config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ export let APP_CONFIG = new OpaqueToken('app.config');
66

77
let heroesRoute = 'heroes';
88
export const AppConfig: IAppConfig = {
9-
title: 'Tour of Heroes',
109
routes: {
1110
heroes: heroesRoute,
1211
heroById: heroesRoute + '/:id'

src/app/config/iapp.config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
export interface IAppConfig {
22
routes: any;
33
endpoints: any;
4-
title: string;
54
}

src/environments/environment.prod.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export const environment = {
2-
production: true
2+
production: true,
3+
title: 'Tour of heroes in prod'
34
};

src/environments/environment.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
// The list of which env maps to which file can be found in `angular-cli.json`.
55

66
export const environment = {
7-
production: false
7+
production: false,
8+
title: 'Tour of heroes in dev'
89
};

0 commit comments

Comments
 (0)