diff --git a/src/app/app.component.html b/src/app/app.component.html index 16768ec..f6c107e 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -4,6 +4,6 @@

Welcome to {{title}}!

- + \ No newline at end of file diff --git a/src/app/app.module.ts b/src/app/app.module.ts index f12a77d..e7e6e2a 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -1,3 +1,4 @@ +import { GitHubService } from './services/github.service'; import { ErrorHandler } from '@angular/core'; import { AppErrorHandler } from './common/app-error-handler'; import { PostService } from './services/post.service'; @@ -17,6 +18,7 @@ import { ContactFormComponent } from './contact-form/contact-form.component'; import { SignupFormComponent } from './signup-form/signup-form.component'; import { ChangePasswordFormComponent } from "./assignments/change-password-form/change-password-form.component"; import { PostsComponent } from './posts/posts.component'; +import { GithubFollowersComponent } from './assignments/github-followers/github-followers.component'; @NgModule({ @@ -31,7 +33,8 @@ import { PostsComponent } from './posts/posts.component'; ContactFormComponent, SignupFormComponent, ChangePasswordFormComponent, - PostsComponent + PostsComponent, + GithubFollowersComponent ], imports: [ BrowserModule, @@ -43,6 +46,7 @@ import { PostsComponent } from './posts/posts.component'; CoursesService, PostService, AppErrorHandler, + GitHubService, { provide: ErrorHandler, useClass: AppErrorHandler} ], bootstrap: [AppComponent] diff --git a/src/app/assignments/github-followers/github-followers.component.css b/src/app/assignments/github-followers/github-followers.component.css new file mode 100644 index 0000000..ee09431 --- /dev/null +++ b/src/app/assignments/github-followers/github-followers.component.css @@ -0,0 +1,5 @@ +.media-object { + width: 80px; + height: 80px; + border-radius: 100%; +} \ No newline at end of file diff --git a/src/app/assignments/github-followers/github-followers.component.html b/src/app/assignments/github-followers/github-followers.component.html new file mode 100644 index 0000000..16504f9 --- /dev/null +++ b/src/app/assignments/github-followers/github-followers.component.html @@ -0,0 +1,15 @@ +

My followers

+
+ Loading... +
+
+
+ + + +
+
+

{{f.login}}

+ {{f.html_url}} +
+
\ No newline at end of file diff --git a/src/app/assignments/github-followers/github-followers.component.spec.ts b/src/app/assignments/github-followers/github-followers.component.spec.ts new file mode 100644 index 0000000..c65b2fa --- /dev/null +++ b/src/app/assignments/github-followers/github-followers.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { GithubFollowersComponent } from './github-followers.component'; + +describe('GithubFollowersComponent', () => { + let component: GithubFollowersComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ GithubFollowersComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(GithubFollowersComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should be created', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/assignments/github-followers/github-followers.component.ts b/src/app/assignments/github-followers/github-followers.component.ts new file mode 100644 index 0000000..094c38b --- /dev/null +++ b/src/app/assignments/github-followers/github-followers.component.ts @@ -0,0 +1,25 @@ +import { GitHubService } from './../../services/github.service'; +import { Component, OnInit, Injectable } from '@angular/core'; + +@Component({ + selector: 'github-followers', + templateUrl: './github-followers.component.html', + styleUrls: ['./github-followers.component.css'] +}) + +export class GithubFollowersComponent implements OnInit { + + followers: any[]; + isLoading = true; + + constructor(private service: GitHubService) { } + + ngOnInit() { + this.service.getAll().subscribe((followers) => { + this.followers = followers; + this.isLoading = false; + }); + + } + +} diff --git a/src/app/services/github.service.ts b/src/app/services/github.service.ts new file mode 100644 index 0000000..e316a93 --- /dev/null +++ b/src/app/services/github.service.ts @@ -0,0 +1,11 @@ +import { Injectable } from '@angular/core'; +import { Http } from '@angular/http'; +import { DataService } from './data.service'; + +@Injectable() +export class GitHubService extends DataService{ + constructor(http: Http){ + super('https://api.github.com/users/dvbtham/followers', http); + + } +} \ No newline at end of file