Skip to content

Commit de090e1

Browse files
committed
section 1
1 parent d1dc324 commit de090e1

9 files changed

+130
-0
lines changed

src/app/home/home.component.html

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<div class="card" style="width: 18rem;">
2+
<div class="card-body">
3+
<h5 class="card-title">Home component</h5>
4+
<p class="card-text">Interceptor will add header to HTTP call</p>
5+
<button class="btn btn-primary" (click)="doHttpCall()">Do Http Call</button>
6+
</div>
7+
</div>
8+
<ng-container>User data: {{data | json}}</ng-container>

src/app/home/home.component.scss

Whitespace-only changes.

src/app/home/home.component.spec.ts

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { HomeComponent } from './home.component';
4+
5+
describe('HomeComponent', () => {
6+
let component: HomeComponent;
7+
let fixture: ComponentFixture<HomeComponent>;
8+
9+
beforeEach(async(() => {
10+
TestBed.configureTestingModule({
11+
declarations: [ HomeComponent ]
12+
})
13+
.compileComponents();
14+
}));
15+
16+
beforeEach(() => {
17+
fixture = TestBed.createComponent(HomeComponent);
18+
component = fixture.componentInstance;
19+
fixture.detectChanges();
20+
});
21+
22+
it('should create', () => {
23+
expect(component).toBeTruthy();
24+
});
25+
});

src/app/home/home.component.ts

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { Component, OnInit } from '@angular/core';
2+
import {HttpClient} from '@angular/common/http';
3+
4+
@Component({
5+
selector: 'app-home',
6+
templateUrl: './home.component.html',
7+
styleUrls: ['./home.component.scss']
8+
})
9+
export class HomeComponent {
10+
11+
data = {};
12+
13+
constructor(private http: HttpClient) { }
14+
15+
doHttpCall() {
16+
this.http.get('https://jsonplaceholder.typicode.com/todos/1').subscribe((data) => {
17+
this.data = data;
18+
});
19+
}
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<p></p>
2+
<div class="card" style="width: 18rem;">
3+
<div class="card-body">
4+
<h5 class="card-title">Lazy loaded component that performs HTTP call!</h5>
5+
<p class="card-text">Interceptor will not add header to HTTP call</p>
6+
<button class="btn btn-primary" (click)="doHttpCall()">Do Http Call</button>
7+
</div>
8+
</div>
9+
<ng-container>User data: {{data | json}}</ng-container>

src/app/some-feature/some-component/some-component.component.scss

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { SomeComponentComponent } from './some-component.component';
4+
5+
describe('SomeComponentComponent', () => {
6+
let component: SomeComponentComponent;
7+
let fixture: ComponentFixture<SomeComponentComponent>;
8+
9+
beforeEach(async(() => {
10+
TestBed.configureTestingModule({
11+
declarations: [ SomeComponentComponent ]
12+
})
13+
.compileComponents();
14+
}));
15+
16+
beforeEach(() => {
17+
fixture = TestBed.createComponent(SomeComponentComponent);
18+
component = fixture.componentInstance;
19+
fixture.detectChanges();
20+
});
21+
22+
it('should create', () => {
23+
expect(component).toBeTruthy();
24+
});
25+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { Component, OnInit } from '@angular/core';
2+
import {HttpClient} from '@angular/common/http';
3+
4+
@Component({
5+
selector: 'app-some-component',
6+
templateUrl: './some-component.component.html',
7+
styleUrls: ['./some-component.component.scss']
8+
})
9+
export class SomeComponentComponent {
10+
11+
data = {};
12+
13+
constructor(private http: HttpClient) { }
14+
15+
doHttpCall() {
16+
this.http.get('https://jsonplaceholder.typicode.com/todos/2').subscribe((data) => {
17+
this.data = data;
18+
});
19+
}
20+
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { NgModule } from '@angular/core';
2+
import { CommonModule } from '@angular/common';
3+
import {SomeComponentComponent} from './some-component/some-component.component';
4+
import {SomeFeatureRoutingModule} from './some-feature-routing.module';
5+
import {HttpClientModule} from '@angular/common/http';
6+
7+
8+
9+
@NgModule({
10+
declarations: [
11+
SomeComponentComponent
12+
],
13+
imports: [
14+
CommonModule,
15+
SomeFeatureRoutingModule,
16+
HttpClientModule
17+
],
18+
bootstrap: [
19+
SomeComponentComponent
20+
]
21+
})
22+
export class SomeFeatureModule { }

0 commit comments

Comments
 (0)