Skip to content

Commit

Permalink
Added dynamic loading for the title
Browse files Browse the repository at this point in the history
  • Loading branch information
colbyhill21 committed Feb 22, 2020
1 parent e115de6 commit a80bde8
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 91 deletions.
130 changes: 48 additions & 82 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"zone.js": "~0.9.1"
},
"devDependencies": {
"@angular-devkit/build-angular": "^0.803.24",
"@angular-devkit/build-angular": "^0.803.25",
"@angular/cli": "~8.2.2",
"@angular/compiler-cli": "~8.2.2",
"@angular/language-service": "~8.2.2",
Expand Down
8 changes: 1 addition & 7 deletions src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,4 @@ <h1 class="timer-text">{{time}}</h1>
</div>
</div>
</div>
</div>




<!--
<router-outlet></router-outlet> -->
</div>
11 changes: 10 additions & 1 deletion src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component } from '@angular/core';

import { Title } from '@angular/platform-browser';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
Expand All @@ -23,6 +23,12 @@ export class AppComponent {
timeLeft: number = this.focusLength * 60;
interval;

public constructor(private titleService: Title ) { }

public setTitle(newTitle: string) {

this.titleService.setTitle( newTitle );
}
focusSelected() {
this.focus = true;
this.shortBreak = false;
Expand Down Expand Up @@ -73,6 +79,7 @@ export class AppComponent {
} else {
this.time += s;
}
this.setTitle("TaskFocus (" + this.time + ")"); //Update the Document Title in Browser
} else {
this.numFocus += 1;
this.startBreak();
Expand All @@ -87,6 +94,8 @@ export class AppComponent {
startBreak() {
if (this.numFocus % 4 === 0) {
this.longBreakSelected();
} else {
this.shortBreakSelected();
}
}

Expand Down

0 comments on commit a80bde8

Please sign in to comment.