-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
490 additions
and
29 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export class Hero { | ||
id: number; | ||
name: string; | ||
} |
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,21 +1,6 @@ | ||
<!--The content below is only a placeholder and can be replaced.--> | ||
<div style="text-align:center"> | ||
<h1> | ||
Welcome to {{ title }}! | ||
</h1> | ||
<img width="300" alt="Angular Logo" src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNTAgMjUwIj4KICAgIDxwYXRoIGZpbGw9IiNERDAwMzEiIGQ9Ik0xMjUgMzBMMzEuOSA2My4ybDE0LjIgMTIzLjFMMTI1IDIzMGw3OC45LTQzLjcgMTQuMi0xMjMuMXoiIC8+CiAgICA8cGF0aCBmaWxsPSIjQzMwMDJGIiBkPSJNMTI1IDMwdjIyLjItLjFWMjMwbDc4LjktNDMuNyAxNC4yLTEyMy4xTDEyNSAzMHoiIC8+CiAgICA8cGF0aCAgZmlsbD0iI0ZGRkZGRiIgZD0iTTEyNSA1Mi4xTDY2LjggMTgyLjZoMjEuN2wxMS43LTI5LjJoNDkuNGwxMS43IDI5LjJIMTgzTDEyNSA1Mi4xem0xNyA4My4zaC0zNGwxNy00MC45IDE3IDQwLjl6IiAvPgogIDwvc3ZnPg=="> | ||
</div> | ||
<h2>Here are some links to help you start: </h2> | ||
<ul> | ||
<li> | ||
<h2><a target="_blank" rel="noopener" href="https://angular.io/tutorial">Tour of Heroes</a></h2> | ||
</li> | ||
<li> | ||
<h2><a target="_blank" rel="noopener" href="https://angular.io/cli">CLI Documentation</a></h2> | ||
</li> | ||
<li> | ||
<h2><a target="_blank" rel="noopener" href="https://blog.angular.io/">Angular blog</a></h2> | ||
</li> | ||
</ul> | ||
|
||
<h1>{{title}}</h1> | ||
<nav> | ||
<a routerLink="/heroes">Heroes</a> | ||
</nav> | ||
<router-outlet></router-outlet> | ||
<app-messages></app-messages> |
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* AppComponent's private CSS styles */ | ||
h1 { | ||
font-size: 1.2em; | ||
color: #999; | ||
margin-bottom: 0; | ||
} | ||
|
||
h2 { | ||
font-size: 2em; | ||
margin-top: 0; | ||
padding-top: 0; | ||
} | ||
|
||
nav a { | ||
padding: 5px 10px; | ||
text-decoration: none; | ||
margin-top: 10px; | ||
display: inline-block; | ||
background-color: #eee; | ||
border-radius: 4px; | ||
} | ||
|
||
nav a:visited, | ||
a:link { | ||
color: #607d8b; | ||
} | ||
|
||
nav a:hover { | ||
color: #039be5; | ||
background-color: #cfd8dc; | ||
} | ||
|
||
nav a.active { | ||
color: #039be5; | ||
} |
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,18 +1,34 @@ | ||
import { BrowserModule } from '@angular/platform-browser'; | ||
import { NgModule } from '@angular/core'; | ||
import { FormsModule } from '@angular/forms'; | ||
import { AppComponent } from './app.component'; | ||
import { HeroesComponent } from './heroes/heroes.component'; | ||
import { HeroDetailComponent } from './hero-detail/hero-detail.component'; | ||
import { MessagesComponent } from './messages/messages.component'; | ||
|
||
import { AppRoutingModule } from './app-routing.module'; | ||
import { AppComponent } from './app.component'; | ||
import { DashboardComponent } from './dashboard/dashboard.component'; | ||
|
||
@NgModule({ | ||
declarations: [ | ||
AppComponent | ||
AppComponent, | ||
HeroesComponent, | ||
HeroDetailComponent, | ||
MessagesComponent, | ||
DashboardComponent, | ||
], | ||
|
||
imports: [ | ||
AppRoutingModule, | ||
BrowserModule, | ||
AppRoutingModule | ||
FormsModule, | ||
], | ||
providers: [], | ||
bootstrap: [AppComponent] | ||
|
||
providers: [ | ||
// no need to place any providers due to the `providedIn` flag... | ||
], | ||
|
||
bootstrap: [ AppComponent ] | ||
}) | ||
|
||
export class AppModule { } |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<p> | ||
dashboard works! | ||
</p> |
Empty file.
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { DashboardComponent } from './dashboard.component'; | ||
|
||
describe('DashboardComponent', () => { | ||
let component: DashboardComponent; | ||
let fixture: ComponentFixture<DashboardComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ DashboardComponent ] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(DashboardComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'app-dashboard', | ||
templateUrl: './dashboard.component.html', | ||
styleUrls: ['./dashboard.component.scss'] | ||
}) | ||
export class DashboardComponent implements OnInit { | ||
|
||
constructor() { } | ||
|
||
ngOnInit() { | ||
} | ||
|
||
} |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<div *ngIf="hero"> | ||
<h2>{{hero.name | uppercase}} Details</h2> | ||
<div><span>id: </span>{{hero.id}}</div> | ||
<div> | ||
<label>name: | ||
<input [(ngModel)]="hero.name" placeholder="name"/> | ||
</label> | ||
</div> | ||
</div> |
Empty file.
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { HeroDetailComponent } from './hero-detail.component'; | ||
|
||
describe('HeroDetailComponent', () => { | ||
let component: HeroDetailComponent; | ||
let fixture: ComponentFixture<HeroDetailComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ HeroDetailComponent ] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(HeroDetailComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Component, OnInit, Input } from '@angular/core'; | ||
import { Hero } from '../hero'; | ||
|
||
@Component({ | ||
selector: 'app-hero-detail', | ||
templateUrl: './hero-detail.component.html', | ||
styleUrls: ['./hero-detail.component.scss'] | ||
}) | ||
export class HeroDetailComponent implements OnInit { | ||
@Input() hero: Hero; | ||
|
||
constructor() { } | ||
|
||
ngOnInit() { | ||
} | ||
|
||
} |
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { TestBed } from '@angular/core/testing'; | ||
|
||
import { HeroService } from './hero.service'; | ||
|
||
describe('HeroService', () => { | ||
beforeEach(() => TestBed.configureTestingModule({})); | ||
|
||
it('should be created', () => { | ||
const service: HeroService = TestBed.get(HeroService); | ||
expect(service).toBeTruthy(); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { Injectable } from '@angular/core'; | ||
|
||
import { Observable, of } from 'rxjs'; | ||
|
||
import { Hero } from './hero'; | ||
import { HEROES } from './mock-heroes'; | ||
import { MessageService } from './message.service'; | ||
|
||
@Injectable({ | ||
providedIn: 'root', | ||
}) | ||
export class HeroService { | ||
|
||
constructor(private messageService: MessageService) { } | ||
|
||
getHeroes(): Observable<Hero[]> { | ||
// TODO: send the message _after_ fetching the heroes | ||
this.messageService.add('HeroService: fetched heroes'); | ||
return of(HEROES); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<h2>My Heroes</h2> | ||
<ul class="heroes"> | ||
<li *ngFor="let hero of heroes" (click)="onSelect(hero)" [class.selected]="hero === selectedHero"> | ||
<span class="badge">{{hero.id}}</span> {{hero.name}} | ||
</li> | ||
</ul> | ||
|
||
<app-hero-detail [hero]="selectedHero"></app-hero-detail> | ||
|
||
<!-- <div *ngIf="selectedHero"> | ||
<h2>{{ selectedHero?.name | uppercase }} details:</h2> | ||
<p>Id: {{ selectedHero?.id }}</p> | ||
<div> | ||
<label>name: | ||
<input [(ngModel)]="selectedHero.name" placeholder="name"/> | ||
</label> | ||
</div> | ||
</div> --> |
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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* HeroesComponent's private CSS styles */ | ||
.selected { | ||
background-color: #CFD8DC !important; | ||
color: white; | ||
} | ||
|
||
.heroes { | ||
margin: 0 0 2em 0; | ||
list-style-type: none; | ||
padding: 0; | ||
width: 15em; | ||
} | ||
|
||
.heroes li { | ||
cursor: pointer; | ||
position: relative; | ||
left: 0; | ||
background-color: #EEE; | ||
margin: .5em; | ||
padding: .3em 0; | ||
height: 1.6em; | ||
border-radius: 4px; | ||
} | ||
|
||
.heroes li.selected:hover { | ||
background-color: #BBD8DC !important; | ||
color: white; | ||
} | ||
|
||
.heroes li:hover { | ||
color: #607D8B; | ||
background-color: #DDD; | ||
left: .1em; | ||
} | ||
|
||
.heroes .text { | ||
position: relative; | ||
top: -3px; | ||
} | ||
|
||
.heroes .badge { | ||
display: inline-block; | ||
font-size: small; | ||
color: white; | ||
padding: 0.8em 0.7em 0 0.7em; | ||
background-color: #607D8B; | ||
line-height: 1em; | ||
position: relative; | ||
left: -1px; | ||
top: -4px; | ||
height: 1.8em; | ||
margin-right: .8em; | ||
border-radius: 4px 0 0 4px; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { HeroesComponent } from './heroes.component'; | ||
|
||
describe('HeroesComponent', () => { | ||
let component: HeroesComponent; | ||
let fixture: ComponentFixture<HeroesComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ HeroesComponent ] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(HeroesComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
|
||
import { Hero } from '../hero'; | ||
import { HeroService } from '../hero.service'; | ||
|
||
@Component({ | ||
selector: 'app-heroes', | ||
templateUrl: './heroes.component.html', | ||
styleUrls: ['./heroes.component.scss'] | ||
}) | ||
export class HeroesComponent implements OnInit { | ||
|
||
selectedHero: Hero; | ||
|
||
heroes: Hero[]; | ||
|
||
constructor(private heroService: HeroService) { } | ||
|
||
ngOnInit() { | ||
this.getHeroes(); | ||
} | ||
|
||
onSelect(hero: Hero): void { | ||
this.selectedHero = hero; | ||
} | ||
|
||
getHeroes(): void { | ||
this.heroService.getHeroes() | ||
.subscribe(heroes => this.heroes = heroes); | ||
} | ||
} |
Oops, something went wrong.