3

This is my code

import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Params, Router } from '@angular/router';

@Component({
  selector: 'app-landing',
  templateUrl: './landing.page.html',
  styleUrls: ['./landing.page.scss'],
})
export class LandingPage implements OnInit {

  constructor(private activatedRoute: ActivatedRoute,
    private router: Router) { }

  ngOnInit() {
    this.activatedRoute.queryParams.subscribe( (params: Params) => {
      console.log(params);
    });
  }

  navigate(query) {
    this.router.navigate(['/landing'], {
      queryParams: {mode: query},
    });
  }

}

My Html code is

<ion-content padding>
  <h3>
      <a (click)="navigate('signIn')" >Sign In</a>
  </h3>
  <h3>
      <a (click)="navigate('signOut')">Sign Out</a>
  </h3>
</ion-content>

Also I tried like

<a fill="clear" [routerLink]="['/landing']" [queryParams]="{'mode':'signIn'}">Tour of Heroes</a>

I'm trying to subscribe the query params. But it is not 'console' the changes when ever there is a change.

It works in 'router-outlet', but not in 'ion-router-outlet' Can some one please tell me what I'm doing wrong here? Thank you.

e.k
  • 1,333
  • 1
  • 17
  • 36

0 Answers0