wijmo.format Method

The wijmo.format method is a provides a way of defining Template Strings. It lets you build strings and meaningful expressions in a familiar way. This sample uses the format method to substitute strings in the template string.

import 'bootstrap.css'; import '@grapecity/wijmo.styles/wijmo.css'; // import * as wijmo from '@grapecity/wijmo'; // document.readyState === 'complete' ? init() : window.onload = init; // function init() { // first example document.querySelector('#btnFormat1').addEventListener('click', () => { let msg = wijmo.format('Welcome {name}! You have {miles:n0} miles in your account.', { name: 'Joe', miles: 2332123 }); alert(msg); }); // // second example document.querySelector('#btnFormat2').addEventListener('click', () => { let msg = wijmo.format('{name}, thanks for being a customer since {date:D}.', { name: 'Joe', date: new Date() }); alert(msg); }); } <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>GrapeCity Globalization/Template Strings</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- SystemJS --> <script src="node_modules/systemjs/dist/system.src.js"></script> <script src="systemjs.config.js"></script> <script> System.import('./src/app'); </script> </head> <body> <div class="container-fluid"> <button id="btnFormat1" class="btn btn-default"> Show First Result </button> <button id="btnFormat2" class="btn btn-default"> Show Second Result </button> </div> </body> </html> import 'bootstrap.css'; import '@grapecity/wijmo.styles/wijmo.css'; // import * as wijmo from '@grapecity/wijmo'; // import { Component, enableProdMode, NgModule } from '@angular/core'; import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; import { BrowserModule } from '@angular/platform-browser'; // @Component({ selector: 'app-component', templateUrl: 'src/app.component.html' }) export class AppComponent { format1() { let msg = wijmo.format('Welcome {name}! You have {miles:n0} miles in your account.', { name: 'Joe', miles: 2332123 }); alert(msg); } // format2() { let msg = wijmo.format('{name}, thanks for being a customer since {date:D}.', { name: 'Joe', date: new Date() }); alert(msg); } } // @NgModule({ imports: [BrowserModule], declarations: [AppComponent], bootstrap: [AppComponent] }) export class AppModule { } // enableProdMode(); // Bootstrap application with hash style navigation and global services. platformBrowserDynamic().bootstrapModule(AppModule); <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>GrapeCity Globalization/Template Strings</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- Polyfills --> <script src="node_modules/core-js/client/shim.min.js"></script> <script src="node_modules/zone.js/dist/zone.min.js"></script> <!-- SystemJS --> <script src="node_modules/systemjs/dist/system.js"></script> <script src="systemjs.config.js"></script> <script> // workaround to load 'rxjs/operators' from the rxjs bundle System.import('rxjs').then(function (m) { System.set(SystemJS.resolveSync('rxjs/operators'), System.newModule(m.operators)); System.import('./src/app.component'); }); </script> </head> <body> <app-component></app-component> </body> </html> <div class="container-fluid"> <button class="btn btn-default" (click)="format1()"> Show First Result </button> <button class="btn btn-default" (click)="format2()"> Show Second Result </button> </div> <template> <div class="container-fluid"> <button class="btn btn-default" @click="format1">Show First Result</button> <button class="btn btn-default" @click="format2">Show Second Result</button> </div> </template> <script> import "bootstrap.css"; import "@grapecity/wijmo.styles/wijmo.css"; import Vue from "vue"; import "@grapecity/wijmo.vue2.nav"; import * as wijmo from "@grapecity/wijmo"; let App = Vue.extend({ name: "app", methods: { format1:function() { let msg = wijmo.format('Welcome {name}! You have {miles:n0} miles in your account.', { name: 'Joe', miles: 2332123 }); alert(msg); }, format2:function() { let msg = wijmo.format('{name}, thanks for being a customer since {date:D}.', { name: 'Joe', date: new Date() }); alert(msg); } } }); new Vue({ render: h => h(App) }).$mount("#app"); </script> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>GrapeCity Globalization/Template Strings</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- SystemJS --> <script src="node_modules/systemjs/dist/system.src.js"></script> <script src="systemjs.config.js"></script> <script> System.import('./src/app.vue'); </script> </head> <body> <div id="app"> </div> </body> </html> import 'bootstrap.css'; import '@grapecity/wijmo.styles/wijmo.css'; import * as React from 'react'; import * as ReactDOM from 'react-dom'; import * as wijmo from "@grapecity/wijmo"; class App extends React.Component { constructor() { super(...arguments); this.format1 = () => { let msg = wijmo.format('Welcome {name}! You have {miles:n0} miles in your account.', { name: 'Joe', miles: 2332123 }); alert(msg); }; this.format2 = () => { let msg = wijmo.format('{name}, thanks for being a customer since {date:D}.', { name: 'Joe', date: new Date() }); alert(msg); }; } render() { return <div className="container-fluid"> <button className="btn btn-default" onClick={this.format1}>Show First Result</button> <button className="btn btn-default" onClick={this.format2}>Show Second Result</button> </div>; } } ReactDOM.render(<App />, document.getElementById('app')); <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>AutoComplete</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- SystemJS --> <script src="node_modules/systemjs/dist/system.src.js"></script> <script src="systemjs.config.js"></script> <script> System.import('./src/app'); </script> </head> <body> <div id="app"></div> </body> </html>