Guest User

Untitled

a guest
Jul 16th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. <div>
  2. <a routerLink="/contact" [queryParams]="sendOBj">Contact me</a>
  3. </div>
  4.  
  5. import { Component, OnInit } from '@angular/core';
  6. import { ActivatedRoute } from '../../../node_modules/@angular/router';
  7. import { FollowersService } from '../followers.service';
  8.  
  9. @Component({
  10. selector: 'app-home',
  11. templateUrl: './home.component.html',
  12. styleUrls: ['./home.component.css']
  13. })
  14. export class HomeComponent implements OnInit {
  15.  
  16. myfollowers: any[];
  17. sendOBj: {id: any, name: any};
  18.  
  19. constructor(private followers: FollowersService, private route: ActivatedRoute) { }
  20.  
  21. ngOnInit() {
  22. this.myfollowers = this.followers.getFollowers();
  23. this.sendOBj = {id: this.myfollowers[0].id, name: this.myfollowers[0].name };
  24. }
  25.  
  26. }
  27.  
  28. import { Component, OnInit } from '@angular/core';
  29. import { ActivatedRoute } from '../../../node_modules/@angular/router';
  30. import { Observable } from '../../../node_modules/rxjs/Observable';
  31. import 'rxjs/observable/combineLatest';
  32.  
  33.  
  34. @Component({
  35. selector: 'app-contact',
  36. templateUrl: './contact.component.html',
  37. styleUrls: ['./contact.component.css']
  38. })
  39. export class ContactComponent implements OnInit {
  40.  
  41. constructor( private route: ActivatedRoute) { }
  42.  
  43. ngOnInit() {
  44.  
  45. Observable.combineLatest([
  46. this.route.queryParamMap
  47. ])
  48. .subscribe(
  49. combined=>{
  50. let id = combined[1].get('id');
  51. console.log('id', id);
  52. }
  53. );
  54.  
  55. this.route.queryParamMap.subscribe();
  56. }
  57. }
Add Comment
Please, Sign In to add comment