# Loading and Saving Documents using Angular

> The TX Text Control JavaScript API enables loading and saving documents in Angular applications via client-side calls. The tutorial covers configuring the Angular component, adding file input handlers, and using the editor API to programmatically open and export documents.

> **Note:** This article is outdated and may no longer be accurate.

- **Author:** Bjoern Meyer
- **Published:** 2019-10-10
- **Modified:** 2026-03-05
- **Description:** The TX Text Control JavaScript API enables loading and saving documents in Angular applications via client-side calls. The tutorial covers configuring the Angular component, adding file input handlers, and using the editor API to programmatically open and export documents.
- **2 min read** (277 words)
- **Tags:**
  - Angular
  - JavaScript
  - Reporting
- **Web URL:** https://www.textcontrol.com/blog/2019/10/10/loading-and-saving-documents-using-angular/
- **LLMs URL:** https://www.textcontrol.com/blog/2019/10/10/loading-and-saving-documents-using-angular/llms.txt
- **LLMs-Full URL:** https://www.textcontrol.com/blog/2019/10/10/loading-and-saving-documents-using-angular/llms-full.txt

---

We recently published the [final release](https://www.textcontrol.com/blog/2020/01/07/tx-text-control-for-angular-released/llms-full.txt) version of our Node.js and Angular implementations that enables developers to use the TX Text Control HTML5-based document editor in pure Angular and Node.js applications.

This tutorial shows how to use the JavaScript API to load and save documents within an Angular application.

1. Create a basic Angular application as described in this tutorial:  
    [Creating your First Angular Application](https://www.textcontrol.com/blog/2020/01/01/creating-an-angular-document-editor-application/llms-full.txt)
2. Create a folder named *js* in the folder *src/assets/* and create a new JavaScript file named *custom.js*.
    
    ```
    function saveDocument() {
        TXTextControl.saveDocument(TXTextControl.StreamType.HTMLFormat,
            function (e) {
                alert(atob(e.data));
            });
    }
    
    function loadDocument() {
        TXTextControl.loadDocument(TXTextControl.StreamType.HTMLFormat,
            btoa('<strong>Test</strong>'));
    }
    ```
3. And add this JavaScript file to the *scripts* array of the projects *architect/build/options* element in the *angular.json* file:
    
    ```
    "scripts": [
      "src/assets/js/custom.js"
    ]
    ```
4. Add the declaration and the methods *onClickSave* and *onClickLoad* to the *app.component.ts* TypeScript file, so that the complete file looks like this:
    
    ```
    import { Component } from '@angular/core';
    declare const saveDocument: any;
    declare const loadDocument: any;
    
    @Component({
      selector: 'app-root',
      templateUrl: './app.component.html',
      styleUrls: ['./app.component.css']
    })
    export class AppComponent {
      title = 'my-editor-app';
    
      onClickSave() {
        saveDocument();
      }
    
      onClickLoad() {
        loadDocument();
      }
    
    }
    ```
5. Finally, add two buttons to the *app.component.html* with the Angular click handlers:
    
    ```
    <tx-document-editor width="1024" height="800" port="8080"></tx-document-editor>
    
    <div>
      <button (click)="onClickLoad()" class="btn btn-primary">Load Document</button>
      <button (click)="onClickSave()" class="btn btn-primary">Save Document</button>
    </div>
    ```

When executing the application, an HTML document is loaded into the editor and the save button alerts the resulting HTML from the *saveDocument* method.

![Loading and saving documents in Angular](https://s1-www.textcontrol.com/assets/dist/blog/2019/10/10/a/assets/angular-load.webp "Loading and saving documents in Angular")

---

## About Bjoern Meyer

As CEO, Bjoern is the visionary behind our strategic direction and business development, bridging the gap between our customers and engineering teams. His deep passion for coding and web technologies drives the creation of innovative products. If you're at a tech conference, be sure to stop by our booth - you'll most likely meet Bjoern in person. With an advanced graduate degree (Dipl. Inf.) in Computer Science, specializing in AI, from the University of Bremen, Bjoern brings significant expertise to his role. In his spare time, Bjoern enjoys running, paragliding, mountain biking, and playing the piano.

- [LinkedIn](https://www.linkedin.com/in/bjoernmeyer/)
- [X](https://x.com/txbjoern)
- [GitHub](https://github.com/bjoerntx)

---

## Related Posts

- [Getting Started: Angular Document Editor Attributes Explained](https://www.textcontrol.com/blog/2023/02/01/getting-started-angular-document-editor-attributes-explained/llms.txt)
- [Getting Started: Programming the Angular Document Editor using JavaScript](https://www.textcontrol.com/blog/2023/01/30/getting-started-programming-the-angular-document-editor-using-javascript/llms.txt)
- [Getting Started: Loading and Saving Documents using Angular](https://www.textcontrol.com/blog/2023/01/30/loading-and-saving-documents-using-angular/llms.txt)
- [Impressions from Web Developer Conference (WDC) in Hamburg](https://www.textcontrol.com/blog/2019/10/16/impressions-from-web-developer-conference/llms.txt)
- [Technology Preview: Embeddable HTML Widget to integrate Document Editing to Angular, React and other Frameworks](https://www.textcontrol.com/blog/2018/03/01/embeddable-html-widget-for-all-frameworks/llms.txt)
- [Getting Started: Document Viewer Version 33.0 with Angular CLI 19.0](https://www.textcontrol.com/blog/2025/03/18/getting-started-document-viewer-version-33-0-with-angular-cli-19-0/llms.txt)
- [Getting Started: Document Editor Version 33.0 with Angular CLI 19.0](https://www.textcontrol.com/blog/2025/03/18/getting-started-document-editor-version-33-0-with-angular-cli-19-0/llms.txt)
- [Getting Started: Document Viewer with Angular CLI v18.0](https://www.textcontrol.com/blog/2024/11/15/getting-started-document-viewer-with-angular-cli-v18-0/llms.txt)
- [Using the Document Editor in SPA Applications using the removeFromDom Method](https://www.textcontrol.com/blog/2024/09/02/using-the-document-editor-in-spa-applications-using-the-removefromdom-method/llms.txt)
- [Observe When the Reporting Preview Tab is Active Using MutationObserver](https://www.textcontrol.com/blog/2024/07/23/observe-when-the-reporting-preview-tab-is-active-using-mutationobserver/llms.txt)
- [Document Viewer for Angular: SignatureSettings Explained](https://www.textcontrol.com/blog/2024/03/20/signaturesettings-explained/llms.txt)
- [Building an ASP.NET Core Backend Application to Host the Document Editor and Document Viewer](https://www.textcontrol.com/blog/2024/03/14/building-an-asp-net-core-backend-application-to-host-the-document-editor-and-document-viewer/llms.txt)
- [Getting Started: Document Editor with Angular CLI v17.0](https://www.textcontrol.com/blog/2023/12/13/getting-started-document-editor-with-angular-cli-17/llms.txt)
- [Angular: Loading Documents from Assets Folder on Initialization](https://www.textcontrol.com/blog/2023/07/10/angular-loading-documents-from-assets-folder-on-initialization/llms.txt)
- [Reuse Angular Document Editor Instances in Bootstrap Tabs](https://www.textcontrol.com/blog/2023/05/22/reuse-angular-document-editor-instances-in-bootstrap-tabs/llms.txt)
- [Getting Started: Document Viewer with Angular CLI](https://www.textcontrol.com/blog/2023/02/02/getting-started-document-viewer-with-angular-cli/llms.txt)
- [Getting Started: Document Editor with Angular CLI](https://www.textcontrol.com/blog/2023/01/30/getting-started-document-editor-with-angular-cli/llms.txt)
- [Getting Started: Document Editor with Angular](https://www.textcontrol.com/blog/2022/09/08/getting-started-document-editor-with-angular/llms.txt)
- [JavaScript: Avoid Flickering and Visual Updates by Grouping Undo Steps](https://www.textcontrol.com/blog/2022/07/25/javascript-avoid-flickering-and-visual-updates-by-grouping-undo-steps/llms.txt)
- [TX Text Control Document Editor Deployment Strategies](https://www.textcontrol.com/blog/2021/08/10/document-editor-deployment-strategies/llms.txt)
- [Track Changes: Show 'Original' and 'No Markup'](https://www.textcontrol.com/blog/2021/02/18/track-changes-show-original-and-no-markup/llms.txt)
- [Using the Document Viewer in Angular Routes](https://www.textcontrol.com/blog/2021/01/14/using-document-viewer-in-angular-routes/llms.txt)
- [Live Samples Hosted on StackBlitz](https://www.textcontrol.com/blog/2020/06/11/live-samples-hosted-on-stackblitz/llms.txt)
- [JavaScript Functions for Typical Form Field Tasks](https://www.textcontrol.com/blog/2020/04/15/javascript-functions-for-typical-form-field-tasks/llms.txt)
- [Using Text Control in Angular Routes](https://www.textcontrol.com/blog/2020/03/30/using-text-control-in-angular-routes/llms.txt)
