Guest User

Untitled

a guest
Nov 15th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. import { Component, OnInit } from '@angular/core';
  2. import { DistrictService } from '../../services/district.service';
  3. import { Router } from '@angular/router';
  4. import { Observable } from 'rxjs';
  5.  
  6. export class ManageAgencysComponent implements OnInit {
  7.  
  8. columnsToDisplay=['name','Date','IsDeleted'];
  9. dataSource= new MatTableDataSource<IAgency>();
  10. constructor(
  11. private router: Router,
  12. private districtService: DistrictService,
  13. ) { }
  14. ngOnInit() {
  15. this.dataSource.data= this.districtService.getAgencyList(false);
  16. }
  17.  
  18. import { Injectable } from '@angular/core';
  19. import { Observable } from 'rxjs/Rx';
  20. import { Response } from '@angular/http';
  21. import { ConfigService } from './config.service';
  22. import { IAgency } from '../interfaces/IAgency';
  23. import { HttpClient } from '@angular/common/http';
  24. import 'rxjs/add/operator/map';
  25.  
  26. @Injectable()
  27. export class DistrictService {
  28.  
  29. constructor(
  30. private _http: HttpClient,
  31. private _config: ConfigService
  32. ) { }
  33. getAgencyList(isDeleted: boolean): Observable<IAgency[]> {
  34. const url = this._config.getAgencyListURL(isDeleted);
  35. return this._http.get<IAgency[]>(url);
  36. }
  37.  
  38. export interface IAgency {
  39. agencyId: number;
  40. agencyName: string;
  41. changeDateStamp: string;
  42. isDeleted: boolean;
  43. }
  44.  
  45. export class Agency implements IAgency {
  46. constructor(
  47. public agencyId: number = 0,
  48. public agencyName: string = '',
  49. public changeDateStamp: string = '',
  50. public isDeleted: boolean = false
  51. ) {}
  52. }
  53.  
  54. import { Component, OnInit } from '@angular/core';
  55. import { DistrictService } from '../../services/district.service';
  56. import { Router } from '@angular/router';
  57. import { Observable } from 'rxjs';
  58.  
  59. export class ManageAgencysComponent implements OnInit {
  60.  
  61. columnsToDisplay=['name','Date','IsDeleted'];
  62. dataSource= new MatTableDataSource<IAgency>();
  63. constructor(
  64. private router: Router,
  65. private districtService: DistrictService,
  66. ) { }
  67. ngOnInit() {
  68. this.districtService.getAgencyList(false).subscribe(result => this.dataSource.data =result);
  69. }
Add Comment
Please, Sign In to add comment