import { Component } from '@angular/core' ; import { QueryParamBuilder , QueryParamGroup } from '@ngqp/core' ; declare const require ; @ Component ( { selector : 'demo-add-remove-parameter-example' , templateUrl : './add-remove-parameter-example.component.html' , } ) export class AddRemoveParameterExampleComponent { public paramGroup : QueryParamGroup ; public markup = require ( '!raw-loader!./add-remove-parameter-example.component.html' ) . default ; public typescript = require ( '!raw-loader!./add-remove-parameter-example.component.ts' ) . default ; constructor ( private qpb ) { this . paramGroup = qpb . group ( { } ) ; this . toggleParam ( ) ; } public get hasParam ( ) : boolean { return ! ! this . paramGroup . get ( 'param' ) ; } public toggleParam ( ) { if ( this . hasParam ) { this . paramGroup . remove ( 'param' ) ; } else { const param = this . qpb . stringParam ( 'q' ) ; this . paramGroup . add ( 'param' , param ) ; } } }