Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tkssharma/ebdb5bfacfc1c3d959d872d22415f094 to your computer and use it in GitHub Desktop.
Save tkssharma/ebdb5bfacfc1c3d959d872d22415f094 to your computer and use it in GitHub Desktop.
import {Component, OnInit} from '@angular/core';
import {HttpClient} from './http.service';
import {user} from './user';
import {Response, Request} from '@angular/http';
@Component({selector: 'my-app', templateUrl: './app.component.html'})
export class AppComponent implements OnInit {
constructor(private Http : HttpClient) {
this.URL ='http://localhost:3000/api';
}
Users : user[];
loaded : boolean;
URL : string;
ngOnInit() {
this.Http.get(this.URL)
.map((response : Response) => response.json())
.subscribe((result) => {
this.Users = result;
this.loaded = true;
});
}
filterValueChange($event:any) {
this.loaded = false;
this.URL = 'http://localhost:3000'+ this.constructUrl($event);
this.Http.get(this.URL)
.map((response : Response) => response.json())
.subscribe((result) => {
this.Users = result;
this.loaded = true;
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment