Advertisement
Guest User

Untitled

a guest
Mar 24th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. @Injectable ()
  2. export class ReportService extends HttpService {
  3.  
  4. public selectedReports: any[] = [];
  5.  
  6. public setSelectedReports (id: string, value: any) {
  7. this.selectedReports[id] = value;
  8. }
  9.  
  10. public removeSelectedReports (id: string) {
  11. delete this.selectedReports[id];
  12. }
  13. }
  14.  
  15. import { ReportService } from './';
  16.  
  17. @Component({
  18. providers: [ReportService]
  19. })
  20.  
  21. export class ReportComponent {
  22. constructor (private reportService: ReportService) {}
  23. }
  24.  
  25. import { ReportService } from '../';
  26. @Component({
  27. template: '<a [routerLink]="['stats']">Stats</a>'
  28. })
  29.  
  30. export class ReportHomeComponent {
  31.  
  32. constructor (private reportService: ReportService) {
  33. reportService.setSelectedReports (1, 'hello')
  34. }
  35. }
  36.  
  37. import { ReportService } from '../';
  38.  
  39. @Component({
  40. })
  41.  
  42. export class ReportStatsComponent {
  43.  
  44. constructor (private reportService: ReportService) {
  45. console.log(reportService.selectedReports)
  46. }
  47. }
  48.  
  49. @Component({
  50. providers: [ReportService]
  51. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement