Skip to content

Commit

Permalink
add progress bar
Browse files Browse the repository at this point in the history
  • Loading branch information
NikosDev committed Apr 2, 2018
1 parent 08d4615 commit 8f7bbd1
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 10 deletions.
17 changes: 17 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
"@angular/platform-browser": "^5.2.0",
"@angular/platform-browser-dynamic": "^5.2.0",
"@angular/router": "^5.2.0",
"@ngx-progressbar/core": "^4.1.1",
"@ngx-progressbar/http": "^4.1.1",
"bootstrap": "^4.0.0",
"core-js": "^2.4.1",
"rxjs": "^5.5.6",
Expand Down
4 changes: 3 additions & 1 deletion src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@
<a href="{{links[i]}}">{{item}}</a>
</li>
</ul>
</div>
</div>

<ng-progress [color]="'green'" [thick]="true" [spinner]="false" ></ng-progress>
20 changes: 12 additions & 8 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
import { Component } from '@angular/core';
import { Component, OnInit } from '@angular/core';
import { WikipediaSearchService } from "./wikipedia-search.service";
import { Subject } from "rxjs/Subject";
import { NgProgress } from '@ngx-progressbar/core';

import 'rxjs/add/operator/debounceTime';
import 'rxjs/add/operator/distinctUntilChanged';
import 'rxjs/add/operator/switchMap';
import 'rxjs/add/operator/do';

@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
export class AppComponent implements OnInit {
items:Array<string>;
links:Array<string>;
term$ = new Subject<string>();

constructor(private service:WikipediaSearchService){
constructor(private service:WikipediaSearchService, public progress: NgProgress){
this.term$
.debounceTime(400)
.distinctUntilChanged()
Expand All @@ -27,10 +29,12 @@ export class AppComponent {
]);
}

search(term: string){
this.service.search(term).subscribe(results => [
this.items= results[1],
this.links= results[3]
])
ngOnInit(){
this.progress.start();
}

ksekina(){
this.progress.start();
}
}

6 changes: 5 additions & 1 deletion src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { HttpClientModule } from '@angular/common/http';
import { NgProgressModule } from '@ngx-progressbar/core';
import { NgProgressHttpModule } from '@ngx-progressbar/http';


import { AppComponent } from './app.component';
Expand All @@ -13,7 +15,9 @@ import { WikipediaSearchService } from "./wikipedia-search.service";
],
imports: [
BrowserModule,
HttpClientModule
HttpClientModule,
NgProgressModule.forRoot(),
NgProgressHttpModule
],
providers: [WikipediaSearchService],
bootstrap: [AppComponent]
Expand Down

0 comments on commit 8f7bbd1

Please sign in to comment.