Can someone tell me all the steps I need to do to use a complete sprintf library (with zero padding and all other features typically present in a standard sprintf) in Angular 2 Typescript component? Thanks.
Install sprintf-js
npm install sprintf-js --save
Install TypeScript Definition
typings install dt~sprintf-js --global --save
Import and use in code
import {sprintf} from "sprintf-js";
console.log(sprintf("%s %s!", "Hello", "Massimo"));
npm i sprintf-js --save
npm i --save_dev @types/sprintf-js
import {sprintf} from "sprintf-js";
As typings is now deprecated:
$ npm install --save @types/sprintf
Then in your typescript source:
import { sprintf } from 'sprintf';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With