Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div>
- <a routerLink="/contact" [queryParams]="sendOBj">Contact me</a>
- </div>
- import { Component, OnInit } from '@angular/core';
- import { ActivatedRoute } from '../../../node_modules/@angular/router';
- import { FollowersService } from '../followers.service';
- @Component({
- selector: 'app-home',
- templateUrl: './home.component.html',
- styleUrls: ['./home.component.css']
- })
- export class HomeComponent implements OnInit {
- myfollowers: any[];
- sendOBj: {id: any, name: any};
- constructor(private followers: FollowersService, private route: ActivatedRoute) { }
- ngOnInit() {
- this.myfollowers = this.followers.getFollowers();
- this.sendOBj = {id: this.myfollowers[0].id, name: this.myfollowers[0].name };
- }
- }
- import { Component, OnInit } from '@angular/core';
- import { ActivatedRoute } from '../../../node_modules/@angular/router';
- import { Observable } from '../../../node_modules/rxjs/Observable';
- import 'rxjs/observable/combineLatest';
- @Component({
- selector: 'app-contact',
- templateUrl: './contact.component.html',
- styleUrls: ['./contact.component.css']
- })
- export class ContactComponent implements OnInit {
- constructor( private route: ActivatedRoute) { }
- ngOnInit() {
- Observable.combineLatest([
- this.route.queryParamMap
- ])
- .subscribe(
- combined=>{
- let id = combined[1].get('id');
- console.log('id', id);
- }
- );
- this.route.queryParamMap.subscribe();
- }
- }
Add Comment
Please, Sign In to add comment