2019-09-12 18:20:54 -04:00
|
|
|
/**
|
|
|
|
* @license
|
2020-05-19 15:08:49 -04:00
|
|
|
* Copyright Google LLC All Rights Reserved.
|
2019-09-12 18:20:54 -04:00
|
|
|
*
|
|
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
|
|
* found in the LICENSE file at https://angular.io/license
|
|
|
|
*/
|
|
|
|
|
|
|
|
import {Component} from '@angular/core';
|
|
|
|
|
2020-09-28 19:12:09 -04:00
|
|
|
/** The most heroic being. */
|
2019-09-19 20:04:02 -04:00
|
|
|
export interface Hero {
|
2019-09-12 18:20:54 -04:00
|
|
|
id: number;
|
|
|
|
name: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'my-app',
|
2020-06-06 01:42:35 -04:00
|
|
|
template: `
|
|
|
|
<h1>{{title}}</h1>
|
|
|
|
<h2>{{hero.name}} details!</h2>
|
2019-09-12 18:20:54 -04:00
|
|
|
`
|
|
|
|
})
|
|
|
|
export class AppComponent {
|
2020-09-28 19:12:09 -04:00
|
|
|
/** This is the title of the `AppComponent` Component. */
|
2019-09-12 18:20:54 -04:00
|
|
|
title = 'Tour of Heroes';
|
|
|
|
hero: Hero = {id: 1, name: 'Windstorm'};
|
2019-09-19 20:04:02 -04:00
|
|
|
private internal: string = 'internal';
|
2020-09-28 19:12:09 -04:00
|
|
|
heroP = Promise.resolve(this.hero);
|
|
|
|
heroes: Hero[] = [this.hero];
|
|
|
|
heroesP = Promise.resolve(this.heroes);
|
|
|
|
tupleArray: [string, Hero] = ['test', this.hero];
|
|
|
|
league: Hero[][] = [this.heroes];
|
|
|
|
heroesByName: {[name: string]: Hero} = {};
|
|
|
|
primitiveIndexType: {[name: string]: string} = {};
|
|
|
|
anyValue: any;
|
|
|
|
optional?: string;
|
|
|
|
// Use to test the `index` variable conflict between the `ngFor` and component context.
|
|
|
|
index = null;
|
|
|
|
myClick(event: any) {}
|
|
|
|
birthday = new Date();
|
|
|
|
readonlyHeroes: ReadonlyArray<Readonly<Hero>> = this.heroes;
|
|
|
|
constNames = [{name: 'name'}] as const;
|
|
|
|
private myField = 'My Field';
|
|
|
|
strOrNumber: string|number = '';
|
2020-06-04 09:35:30 -04:00
|
|
|
setTitle(newTitle: string) {
|
|
|
|
this.title = newTitle;
|
|
|
|
}
|
2019-09-12 18:20:54 -04:00
|
|
|
}
|