docs: refactor style guide example 01-01 (#22738)
docs: refactor style guide example 01-01 PR Close #22738
This commit is contained in:
parent
4834fdaf59
commit
d3656bcecc
@ -9,6 +9,6 @@ import { HeroService } from './heroes';
|
|||||||
<toh-heroes></toh-heroes>
|
<toh-heroes></toh-heroes>
|
||||||
`,
|
`,
|
||||||
styleUrls: ['./app.component.css'],
|
styleUrls: ['./app.component.css'],
|
||||||
providers: [ HeroService ]
|
providers: [HeroService]
|
||||||
})
|
})
|
||||||
export class AppComponent { }
|
export class AppComponent {}
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
// #docregion
|
// #docregion
|
||||||
/* avoid */
|
/* avoid */
|
||||||
|
import { Component, NgModule, OnInit } from '@angular/core';
|
||||||
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
|
||||||
import { BrowserModule } from '@angular/platform-browser';
|
import { BrowserModule } from '@angular/platform-browser';
|
||||||
import { NgModule, Component, OnInit } from '@angular/core';
|
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
||||||
|
|
||||||
class Hero {
|
class Hero {
|
||||||
id: number;
|
id: number;
|
||||||
@ -24,24 +23,24 @@ class AppComponent implements OnInit {
|
|||||||
heroes: Hero[] = [];
|
heroes: Hero[] = [];
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
getHeroes().then(heroes => this.heroes = heroes);
|
getHeroes().then(heroes => (this.heroes = heroes));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [ BrowserModule ],
|
imports: [BrowserModule],
|
||||||
declarations: [ AppComponent ],
|
declarations: [AppComponent],
|
||||||
exports: [ AppComponent ],
|
exports: [AppComponent],
|
||||||
bootstrap: [ AppComponent ]
|
bootstrap: [AppComponent]
|
||||||
})
|
})
|
||||||
export class AppModule { }
|
export class AppModule {}
|
||||||
|
|
||||||
platformBrowserDynamic().bootstrapModule(AppModule);
|
platformBrowserDynamic().bootstrapModule(AppModule);
|
||||||
|
|
||||||
const HEROES: Hero[] = [
|
const HEROES: Hero[] = [
|
||||||
{id: 1, name: 'Bombasto'},
|
{ id: 1, name: 'Bombasto' },
|
||||||
{id: 2, name: 'Tornado'},
|
{ id: 2, name: 'Tornado' },
|
||||||
{id: 3, name: 'Magneta'},
|
{ id: 3, name: 'Magneta' }
|
||||||
];
|
];
|
||||||
|
|
||||||
function getHeroes(): Promise<Hero[]> {
|
function getHeroes(): Promise<Hero[]> {
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
import { Hero } from './hero.model';
|
import { Hero } from './hero.model';
|
||||||
|
|
||||||
export const HEROES: Hero[] = [
|
export const HEROES: Hero[] = [
|
||||||
{id: 1, name: 'Bombasto'},
|
{ id: 1, name: 'Bombasto' },
|
||||||
{id: 2, name: 'Tornado'},
|
{ id: 2, name: 'Tornado' },
|
||||||
{id: 3, name: 'Magneta'},
|
{ id: 3, name: 'Magneta' }
|
||||||
];
|
];
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// #docregion
|
// #docregion
|
||||||
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
||||||
|
|
||||||
import { AppModule } from './app/app.module';
|
import { AppModule } from './app/app.module';
|
||||||
|
|
||||||
platformBrowserDynamic().bootstrapModule(AppModule);
|
platformBrowserDynamic().bootstrapModule(AppModule);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user