The ng-util library export lots of utility functions which you need in your day-to-day angular app development. Our main intent is to make developer life easy by saving lots of time which we spent on googling and finding the right code or reinventing the wheel.
$ npm install ng-util
import { Component } from '@angular/core';
import { StringUtilService } from 'ng-util';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
providers:[StringUtilService]
})
export class AppComponent {
query: string;
title = 'app';
constructor(private strUtil: StringUtilService) {
this.query = this.strUtil.jsonToQueryString({
id: 10,
name: 'tom'
});
}
}
<h2>Query:{{ query }}! </h2>
Query: ?id=10&name=tom