30 lines
741 B
TypeScript
30 lines
741 B
TypeScript
|
// #docplaster
|
||
|
// #docregion
|
||
|
// Import the native Angular services.
|
||
|
import { Component } from 'angular2/core';
|
||
|
import { Title } from 'angular2/platform/browser';
|
||
|
|
||
|
@Component({
|
||
|
selector: 'my-app',
|
||
|
template:
|
||
|
`<p>
|
||
|
Select a title to set on the current HTML document:
|
||
|
</p>
|
||
|
|
||
|
<ul>
|
||
|
<li><a (click)="setTitle( 'Good morning!' )">Good morning</a>.</li>
|
||
|
<li><a (click)="setTitle( 'Good afternoon!' )">Good afternoon</a>.</li>
|
||
|
<li><a (click)="setTitle( 'Good evening!' )">Good evening</a>.</li>
|
||
|
</ul>
|
||
|
`
|
||
|
})
|
||
|
// #docregion class
|
||
|
export class AppComponent {
|
||
|
public constructor(private _titleService: Title ) { }
|
||
|
|
||
|
public setTitle( newTitle: string) {
|
||
|
this._titleService.setTitle( newTitle );
|
||
|
}
|
||
|
}
|
||
|
// #enddocregion class
|