AngularJS
Angular Integration Guide
DimensionIQWidget Integration
This section explains how to integrate the
Overview
The
- The engine URL
- A set of callbacks used to communicate with the host application
These callbacks allow the widget to interact with your application's data layer, enabling project creation, revisions, drawing uploads, and other operational features.
In a production environment, these callbacks typically communicate with a backend API, database, or remote storage service to persist and retrieve project data.
Component Structure
The example Angular component performs the following tasks:
-
Defines a container element for the widget.
-
Initializes the widget after the view has loaded.
-
Provides example callback implementations.
-
Unmounts the widget when the component is destroyed.
The widget is mounted using the provided
Widget Container
The widget requires a container element where it will be rendered.

<div #widgetContainer style="width:100%;height:500px"></div>
The container reference is accessed using Angular's
@ViewChild('widgetContainer', { static: true })
containerRef!: ElementRef<HTMLDivElement>;
Initializing the Widget
The widget is initialized in the
const widgetProps: DimensionIQWidgetProps = {
engineURL: '',
callbacks: {}
};
The configuration object contains the required properties used by the widget.
Engine URL
widgetProps.engineURL = '/';
The
- The rendering engine
- Supporting assets
- Font files
- Additional runtime resources required by the widget
In most deployments, the engine URL points to a directory on your web server or CDN that hosts the widget engine distribution.
Example:
/dimension-iq-engine/
or
https://cdn.yourdomain.com/diq-engine/
Widget Callbacks
The widget communicates with the host application through a set of callbacks. These callbacks allow the widget to request actions such as creating projects, adding revisions, or retrieving stored data.
The callbacks in this example are intentionally simple and primarily log information to the console. They return successful responses without performing any real storage operations.
In a real application, these callbacks would typically:
- Call a REST API
- Send or retrieve data from a database
- Communicate with a remote storage service
Basic Angular Integration of the DimensionIQWidget
This example shows how to integrate the
A
The widget is unmounted in
import {
Component,
AfterViewInit,
ElementRef,
ViewChild,
OnDestroy
} from '@angular/core';
import type {
DimensionIQWidgetProps,
DIQ_DrawingRevision,
DIQ_Layout,
DIQ_Project,
DIQ_Result,
DIQ_Revision
} from '../types/dimension-iq-widget.es';
import { mount } from '../lib/dimension-iq-widget.es.js';
@Component({
selector: 'app-root',
template: `<div #widgetContainer style="width:100%;height:500px"></div>`
})
export class AppComponent implements AfterViewInit, OnDestroy {
@ViewChild('widgetContainer', { static: true })
containerRef!: ElementRef<HTMLDivElement>;
unmount: any;
ngAfterViewInit() {
const widgetProps: DimensionIQWidgetProps = {
engineURL: '',
callbacks: {}
};
widgetProps.engineURL = '/';
widgetProps.callbacks.onProjectNew = async function (
project: DIQ_Project | null,
onResponse: (result: DIQ_Result) => void
) {
console.log(project);
console.log(onResponse);
onResponse({ ok: true, message: '' });
};
widgetProps.callbacks.onRevisionNew = async function (
revision: DIQ_Revision | null,
onResponse: (result: DIQ_Result) => void
) {
console.log(revision);
onResponse({ ok: true, message: '' });
};
widgetProps.callbacks.onDrawingNew = async function (
drawing: DIQ_DrawingRevision | null,
layouts: Array<DIQ_Layout>,
onResponse: (result: DIQ_Result) => void
) {
console.log(drawing);
console.log(layouts);
onResponse({ ok: true, message: '' });
};
widgetProps.callbacks.onListRevisions = async function (
project: DIQ_Project,
onResponse: (
result: DIQ_Result,
revisions: Array<DIQ_Revision> | null
) => void
) {
console.log(project);
const revisions: Array<DIQ_Revision> = [];
revisions.push({
key: 'unique-revison-key',
projectKey: project.key,
number: 1,
name: 'Revision 1',
notes: ''
});
onResponse({ ok: true, message: '' }, revisions);
};
this.unmount = mount(this.containerRef.nativeElement, widgetProps);
}
ngOnDestroy() {
this.unmount();
}
}