import { Injectable } from '@angular/core' ; import { FormGroup } from '@angular/forms' ; import { ActivatedRoute , Params , Router } from '@angular/router' ; export interface QueryParams { q : string ; } @ Injectable ( { providedIn : 'root' , } ) export class DeepLinkService { constructor ( private router , private route ) { } param form registerFormGroup ( form ) { this . route . queryParams . subscribe ( ( query ) => { if ( query . q ) { form . setValue ( { query : query . q , } ) ; } } ) ; } param queryParams syncUrl ( queryParams ) { this . router . navigate ( [ ] , { relativeTo : this . route , queryParams , } ) ; } }