-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from OpenLiberty/hotspottags
Converted hotspot line numbers to tags
- Loading branch information
Showing
4 changed files
with
104 additions
and
47 deletions.
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
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 |
---|---|---|
@@ -1,10 +1,16 @@ | ||
<!-- tag::artistsDiv[] --> | ||
<div *ngFor="let artist of artists"> | ||
<!-- tag::artistNameAndAlbumsLengthPlaceholders[] --> | ||
<p>{{ artist.name }} wrote {{ artist.albums.length }} albums: </p> | ||
<!-- end::artistNameAndAlbumsLengthPlaceholders[] --> | ||
<!-- tag::albumDiv[] --> | ||
<div *ngFor="let album of artist.albums"> | ||
<p style="text-indent: 20px"> | ||
Album titled <b>{{ album.title }}</b> by | ||
<b>{{ album.artist }}</b> contains | ||
<b>{{ album.ntracks }}</b> tracks | ||
</p> | ||
</div> | ||
<!-- end::albumDiv[] --> | ||
</div> | ||
<!-- end::artistsDiv[] --> |
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 |
---|---|---|
@@ -1,37 +1,79 @@ | ||
// tag::importOnInitAndAngularCorePackage[] | ||
import { Component, OnInit } from '@angular/core'; | ||
// end::importOnInitAndAngularCorePackage[] | ||
// tag::importHttpClient[] | ||
import { HttpClient } from '@angular/common/http'; | ||
// end::importHttpClient[] | ||
// tag::importInjectable[] | ||
import { Injectable } from '@angular/core'; | ||
// end::importInjectable[] | ||
|
||
// tag::atInjectable[] | ||
@Injectable() | ||
// end::atInjectable[] | ||
// tag::artistsServiceClass[] | ||
export class ArtistsService { | ||
// tag::httpClientInstance[] | ||
constructor(private http: HttpClient) { } | ||
// end::httpClientInstance[] | ||
|
||
// tag::artistsUrl[] | ||
private static ARTISTS_URL = '/artists'; | ||
// end::artistsUrl[] | ||
|
||
// tag::fetchArtistsMethod[] | ||
// tag::asyncFeature[] | ||
async fetchArtists() { | ||
// end::asyncFeature[] | ||
try { | ||
// tag::httpInstanceAndAwaitFeatureAndHttpGetAndToPromise[] | ||
const data: any = await this.http.get(ArtistsService.ARTISTS_URL).toPromise(); | ||
// end::httpInstanceAndAwaitFeatureAndHttpGetAndToPromise[] | ||
return data; | ||
} catch (error) { | ||
console.error(`Error occurred: ${error}`); | ||
} | ||
} | ||
// end::fetchArtistsMethod[] | ||
} | ||
// end::artistsServiceClass[] | ||
|
||
// tag::atComponent[] | ||
@Component({ | ||
selector: 'app-root', | ||
// tag::templateUrl[] | ||
templateUrl: './app.component.html', | ||
// end::templateUrl[] | ||
// tag::providersProperty[] | ||
providers: [ ArtistsService ], | ||
// end::providersProperty[] | ||
// tag::styleUrls[] | ||
styleUrls: ['./app.component.css'] | ||
// end::styleUrls[] | ||
}) | ||
// end::atComponent[] | ||
// tag::appComponentClass[] | ||
// tag::onInitInterface[] | ||
export class AppComponent implements OnInit { | ||
// end::onInitInterface[] | ||
// tag::artistsClassMember[] | ||
artists: any[] = []; | ||
// end::artistsClassMember[] | ||
|
||
// tag::artistsServiceInstanceDeclaration[] | ||
constructor(private artistsService: ArtistsService) { } | ||
// end::artistsServiceInstanceDeclaration[] | ||
|
||
// tag::ngOnInitMethod[] | ||
ngOnInit() { | ||
// tag::thenClause[] | ||
// tag::artistsServiceInstance[] | ||
this.artistsService.fetchArtists().then(data => { | ||
// end::artistsServiceInstance[] | ||
this.artists = data; | ||
}); | ||
// end::thenClause[] | ||
} | ||
// end::ngOnInitMethod[] | ||
} | ||
// end::appComponentClass[] |
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 |
---|---|---|
@@ -1,18 +1,25 @@ | ||
import { BrowserModule } from '@angular/platform-browser'; | ||
import { NgModule } from '@angular/core'; | ||
// tag::importHttpClientModule[] | ||
import { HttpClientModule } from '@angular/common/http'; | ||
|
||
// end::importHttpClientModule[] | ||
import { AppComponent } from './app.component'; | ||
|
||
// tag::atNgModule[] | ||
@NgModule({ | ||
declarations: [ | ||
AppComponent | ||
], | ||
// tag::importsArray[] | ||
imports: [ | ||
BrowserModule, | ||
// tag::httpClientModule[] | ||
HttpClientModule, | ||
// end::httpClientModule[] | ||
], | ||
// end::importsArray[] | ||
providers: [], | ||
bootstrap: [AppComponent] | ||
}) | ||
// end::atNgModule[] | ||
export class AppModule { } |