Angular: Loading Excerpt JSON Data on Initializing TX Text Control
Data excerpt files are used to provide the data structure that is used to fill the merge field drop-down lists and for mail merge preview purposes. This article shows how to load JSON data into the Angular editor.

TX Text Control for Angular provides a fully-featured mail merge UI to insert merge fields and repeating merge blocks into a document. The drop-down Insert Merge Field is used to insert available merge fields:
To help users to insert only valid merge fields, the required data structure can be loaded using the load
Available fields and child objects are listed hierarchically in the merge field lists. The following JSON string has been used in this sample:
[
{
"Id":1,
"Name":"Invoice",
"Orders":[
{
"Id":1,
"OrderItems":[
{
"Id":1,
"Qty":5,
"Product":{
"Id":1,
"Name":"TX Spell .NET",
"Description":"Spell checking component",
"Available":true,
"Price":249.56,
"Serial":"AA6765653"
},
"Price":200.56
},
{
"Price":4433.44
}
]
}
]
}
]
The JSON data can be loaded using the loadJsonData JavaScript method:
function loadJsonData(json)
{
TXTextControl.loadJsonData(json);
}
In order to initialize TX Text Control with that data, you can load the excerpt file in the ribbon
import { Component, HostListener } from '@angular/core';
declare const TXTextControl: any;
declare const loadDocument: any;
declare const loadJsonData: any;
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
// attach the txDocumentEditorLoaded event in the @HostListener decorator
// https://angular.io/api/core/HostListener
@HostListener('document:txDocumentEditorLoaded', ['$event'])
onTxDocumentEditorLoaded() {
var jsonData = '[{"Id":1,"Name":"Invoice","Orders":[{"Id":1,"OrderItems":[{"Id":1,"Qty":5,"Product":{"Id":1,"Name":"TX Spell .NET","Description":"Spell checking component","Available":true,"Price":249.56,"Serial":"AA6765653"},"Price":200.56},{"Price":4433.44}]}]}]';
// wait until TXTextControl has been loaded
TXTextControl.addEventListener("ribbonTabsLoaded", function() {
loadJsonData(jsonData);
});
}
}
Test this on your own and create your trial access token today.
Also See
This post references the following in the documentation:
- Javascript: TXText
Control.load Json Data Method
Angular
Integrate document processing, editing, sharing, collaboration, creation, electronic signatures, and PDF generation into your Angular Web applications.
Related Posts
Angular: Loading Documents on Initializing TX Text Control
With the latest version 28.3.0, the Angular document editor received a new event that is fired when TXTextControl is available. This event can be used to access the object and to attach additional…
AngularASP.NET CoreDocument Viewer
Asynchronous Loading and Saving in Angular Document Editor with an ASP.NET…
This article shows how to load and save documents in an Angular Document Editor using an ASP.NET Core Web API asynchronously. A Web API is used to load and save documents from and to the server…
Getting Started: Loading and Saving Documents using Angular
This article shows how to load and save documents using the Angular Document Editor. It explains how to use the Angular Document Editor in an Angular application and how to load from a URL and how…
Creating PDF Documents from MS Word DOCX in C#
TX Text Control provides an elegant way to create Adobe PDF documents by merging data into MS Word DOCX templates. The developer libraries can be used in any platform including ASP.NET Core,…
AngularDocument SigningLoading
Signing Documents with the Angular DocumentViewer
The TX Text Control DocumentViewer for Angular can be used to request signatures for an electronic document signing process. This tutorial shows how to request a signature.