-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(playground): add title handling example
- Loading branch information
Showing
5 changed files
with
83 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import * as angular from 'angular'; | ||
import { provide } from 'ng-metadata/core'; | ||
|
||
import { TitleHandlerComponent } from './title-handler.component'; | ||
|
||
export const TitleHandlerModule = angular | ||
.module( 'titleHandler', [] ) | ||
.directive( ...provide( TitleHandlerComponent ) ) | ||
.name; |
27 changes: 27 additions & 0 deletions
27
playground/app/components/title/title-handler.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Import the native Angular services. | ||
import { Component } from 'ng-metadata/core'; | ||
import { Title } from 'ng-metadata/platform'; | ||
|
||
@Component({ | ||
selector: 'my-title-handler', | ||
template: ` | ||
<p>Document title is: {{ $ctrl.title }}</p> | ||
<p> | ||
Select a title to set on the current HTML document: | ||
</p> | ||
<ul> | ||
<li><a ng-click="$ctrl.setTitle( 'Good morning!' )">Good morning</a>.</li> | ||
<li><a ng-click="$ctrl.setTitle( 'Good afternoon!' )">Good afternoon</a>.</li> | ||
<li><a ng-click="$ctrl.setTitle( 'Good evening!' )">Good evening</a>.</li> | ||
</ul> | ||
` | ||
}) | ||
export class TitleHandlerComponent { | ||
constructor(private titleService: Title ) {} | ||
|
||
get title(): string { return this.titleService.getTitle() } | ||
|
||
setTitle( newTitle: string) { | ||
this.titleService.setTitle( newTitle ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters