docs: refactor style guide example 01-01 (#22738)

docs: refactor style guide example 01-01


PR Close #22738
This commit is contained in:
Daniel 2018-07-11 18:27:54 +02:00 committed by Victor Berchet
parent 6b859daea4
commit 4d6f467fea
4 changed files with 17 additions and 18 deletions

View File

@ -9,6 +9,6 @@ import { HeroService } from './heroes';
<toh-heroes></toh-heroes>
`,
styleUrls: ['./app.component.css'],
providers: [ HeroService ]
providers: [HeroService]
})
export class AppComponent { }
export class AppComponent {}

View File

@ -1,9 +1,8 @@
// #docregion
/* avoid */
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { Component, NgModule, OnInit } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { NgModule, Component, OnInit } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
class Hero {
id: number;
@ -24,24 +23,24 @@ class AppComponent implements OnInit {
heroes: Hero[] = [];
ngOnInit() {
getHeroes().then(heroes => this.heroes = heroes);
getHeroes().then(heroes => (this.heroes = heroes));
}
}
@NgModule({
imports: [ BrowserModule ],
declarations: [ AppComponent ],
exports: [ AppComponent ],
bootstrap: [ AppComponent ]
imports: [BrowserModule],
declarations: [AppComponent],
exports: [AppComponent],
bootstrap: [AppComponent]
})
export class AppModule { }
export class AppModule {}
platformBrowserDynamic().bootstrapModule(AppModule);
const HEROES: Hero[] = [
{id: 1, name: 'Bombasto'},
{id: 2, name: 'Tornado'},
{id: 3, name: 'Magneta'},
{ id: 1, name: 'Bombasto' },
{ id: 2, name: 'Tornado' },
{ id: 3, name: 'Magneta' }
];
function getHeroes(): Promise<Hero[]> {

View File

@ -2,7 +2,7 @@
import { Hero } from './hero.model';
export const HEROES: Hero[] = [
{id: 1, name: 'Bombasto'},
{id: 2, name: 'Tornado'},
{id: 3, name: 'Magneta'},
{ id: 1, name: 'Bombasto' },
{ id: 2, name: 'Tornado' },
{ id: 3, name: 'Magneta' }
];

View File

@ -1,6 +1,6 @@
// #docregion
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module';
import { AppModule } from './app/app.module';
platformBrowserDynamic().bootstrapModule(AppModule);