Skip to content

Commit f797b7a

Browse files
committed
feat(directive): added shared module and highlight directive
1 parent a568742 commit f797b7a

19 files changed

Lines changed: 91 additions & 65 deletions

.gitignore

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,7 @@
11
.idea/workspace.xml
2-
.idea/tasks.xml
32
.idea/
4-
.idea/dataSources/
5-
.idea/dataSources.ids
6-
.idea/dataSources.xml
7-
.idea/dataSources.local.xml
8-
.idea/sqlDataSources.xml
9-
.idea/dynamic.xml
10-
.idea/uiDesigner.xml
11-
.idea/gradle.xml
12-
.idea/libraries
13-
*.iws
143

15-
.idea_modules/
164
node_modules/
17-
npm-debug.log
185

196
app/**/*.js
207
app/**/*.map

app/app.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
<h1 tohHighlight>{{title}}</h1>
1+
<h1>{{title}}</h1>
22
<toh-nav></toh-nav>
33
<router-outlet></router-outlet>

app/app.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { APP_CONFIG, IAppConfig } from './app.config';
1111

1212
export class AppComponent {
1313
title: string;
14-
14+
1515
constructor(@Inject(APP_CONFIG) private appConfig: IAppConfig) {
1616
this.title = this.appConfig.title;
1717
}

app/app.module.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { HttpModule } from '@angular/http';
66
import { APP_CONFIG, AppConfig } from './app.config';
77

88
import { AppRoutingModule } from './app-routing.module';
9+
import { SharedModule } from './shared/shared.module';
910
import { CoreModule } from './core/core.module';
1011
import { HeroesModule } from './heroes/heroes.module';
1112

@@ -15,8 +16,6 @@ import { InMemoryDataService } from './shared/in-memory-data.service';
1516
import { AppComponent } from './app.component';
1617
import { HeroTopComponent } from './heroes/hero-top/hero-top.component';
1718

18-
import { HighlightDirective } from "./shared/highlight.directive";
19-
2019
import './shared/rxjs-extensions';
2120

2221
@NgModule({
@@ -27,12 +26,12 @@ import './shared/rxjs-extensions';
2726
InMemoryWebApiModule.forRoot(InMemoryDataService),
2827
AppRoutingModule,
2928
CoreModule,
30-
HeroesModule
29+
HeroesModule,
30+
SharedModule
3131
],
3232
declarations: [
3333
AppComponent,
34-
HeroTopComponent,
35-
HighlightDirective
34+
HeroTopComponent
3635
],
3736
providers: [
3837
{ provide: APP_CONFIG, useValue: AppConfig }

app/core/logger.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export class LoggerService {
55
log(msg: string) {
66
console.log(msg);
77
}
8-
8+
99
error(msg: string, obj?: any) {
1010
console.error(msg, obj);
1111
}

app/core/nav/nav.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { APP_CONFIG, IAppConfig } from './../../app.config';
1111

1212
export class NavComponent {
1313
menuItems;
14-
14+
1515
constructor(@Inject(APP_CONFIG) private appConfig: IAppConfig) {
1616
this.menuItems = [
1717
{ link: '/', name: 'Home' },

app/heroes/hero-detail/hero-detail.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ import { HeroService } from './../shared/hero.service';
1414

1515
export class HeroDetailComponent implements OnInit {
1616
hero: Hero;
17-
17+
1818
constructor(private heroService: HeroService,
1919
private route: ActivatedRoute,
2020
private location: Location) {
2121
}
22-
22+
2323
ngOnInit(): void {
2424
this.route.params
2525
.switchMap((params: Params) => this.heroService.getHeroById(+params[ 'id' ]))
@@ -30,7 +30,7 @@ export class HeroDetailComponent implements OnInit {
3030
this.heroService.update(this.hero)
3131
.then(() => this.goBack());
3232
}
33-
33+
3434
goBack(): void {
3535
this.location.back();
3636
}

app/heroes/hero-form/hero-form.component.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
.form-group {
2+
margin: 1em 0 1em 0;
3+
}
4+
15
.form-label {
26
display: inline-block;
37
width: 10%;

app/heroes/hero-form/hero-form.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ import { HeroService } from './../shared/hero.service';
1414
export class HeroFormComponent {
1515
@Input() heroes: Hero[];
1616
@Input() selectedHero: Hero;
17-
17+
1818
hero: Hero;
1919
submitted: boolean;
2020
powers: string[];
21-
21+
2222
constructor(private heroService: HeroService) {
2323
this.hero = new Hero(-1, '', '');
2424
this.submitted = false;
Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
1-
<h2>My Heroes</h2>
2-
<br>
31
<toh-hero-form [heroes]="heroes"
42
[selectedHero]="selectedHero">
53
</toh-hero-form>
64
<br>
5+
<h4>Pick a highlight color</h4>
6+
<div>
7+
<input type="radio" name="colors" (click)="color='lightgreen'">Green
8+
<input type="radio" name="colors" (click)="color='yellow'">Yellow
9+
<input type="radio" name="colors" (click)="color='cyan'">Cyan
10+
</div>
11+
<br>
12+
<h2>My Heroes</h2>
713
<ul class="heroes">
814
<li *ngFor="let hero of heroes" (click)="onSelect(hero)"
9-
[class.selected]="hero === selectedHero">
15+
[class.selected]="hero === selectedHero"
16+
[tohHighlight]="color" defaultColor="violet">
1017
<span class="badge">{{hero.id}}</span>
1118
<span>{{hero.name}} | {{hero.alterEgo}} | {{hero.power}}</span>
1219
<button class="remove"
@@ -18,6 +25,5 @@ <h2>My Heroes</h2>
1825
<h2>
1926
{{selectedHero.name | uppercase}} is my hero
2027
</h2>
21-
<p tohHighlight>Test</p>
2228
<button (click)="gotoDetail()">View Details</button>
2329
</div>

0 commit comments

Comments
 (0)