Tips on integrating ActiveX controls in Angular

I built my project using Angular 6 and TypeScript in Visual Studio Code. The browser being used is IE11.

Unfortunately, when I try to run the code written in app.component.html, it doesn't work as expected.

The HTML code causing the issue is:

<div>
  <div >
    <object ID="activexFirst" CLASSID="CLSID:xxxxx-xxx" width="300" height="200"></object>
  </div>
  <div>
    <object ID="activeSencod" classid="CLSID:xxxxx-xxx" width="600" height="500"></object>
  </div>
</div>

The TypeScript code in app.component.ts looks like this:

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css'],
  encapsulation: ViewEncapsulation.None,
})
export class AppComponent implements AfterViewInit {
//todo..
}

Interestingly, if I write the code directly in Index.html, it works fine. How can I resolve this issue?

Answer №1

Perhaps the angular-element is distinct from a native HTML element, but now everything seems to be working fine. Here is the code snippet from app.component.ts:

 ngAfterViewInit(): void {

    ActiveX.SetActiveXHtml(this.tActive1Div);
  }

And this is what you can find in ActiveX.ts file:

public static SetActiveXHtml(activeXDiv: ElementRef): void {
        let obj = document.getElementById('simplename') as any;
        if (obj == null) {
            obj = document.createElement('object');
            obj.name = 'name';
            obj.id = 'name';
            obj.classid = 'CLSID:xxxxxxxxxxxxxxxxx';
        }
        const cloneObj = obj.cloneNode(true);
        activeXDiv.nativeElement.appendChild(cloneObj);
    }

Remember, the cloneNode method plays a crucial role here!

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Material UI React Autocomplete Component

I'm currently working on integrating an Autocomplete component using the Material UI library. However, I've encountered a challenge - I'm unsure of how to properly pass the value and onChange functions, especially since I have a custom Text ...

Managing errors with the RxJS retry operator

I'm facing an issue with my RxJS code where I need to continuously retry a data request upon failure while also handling the error. Currently, I am using the retry operator for this purpose. However, when attempting to subscribe to the retry operator ...

"Utilize Typescript for defining the parameter type in this

defineProperties(Element.prototype, { querySelector: { value: querySelectorPatched, writable: true, enumerable: true, configurable: true, }, querySelectorAll: { value(this: HTMLBodyElement): NodeListOf< ...

How to resolve the issue of any data type in Material UI's Textfield

I am seeking clarity on how to resolve the TypeScript error indicating that an element has an 'any' type, and how I can determine the appropriate type to address my issue. Below is a snippet of my code: import { MenuItem, TextField } from '@ ...

In my Angular application, the Authentication JWT is securely stored by Firebase within the Session Storage. Does this implementation pose any security risks

In order to enhance the user experience of our Angular app, we have integrated Firebase Authentication with Session Persistence. This ensures that users don't need to log in again every time they refresh the page. As part of this process, we store the ...

Calculate the total values across a row of a work schedule, based on specific conditions

I am facing a challenge with my work schedule data, as it is laid out horizontally. I am trying to calculate the total hours in the schedule based on various criteria such as the person's name, their available hours, shift, and the machine they are as ...

Is it possible to place Angular Material components using code?

Currently, I'm in the process of creating a responsive Angular application. Is there any way to adjust the height and position of the <mat-sidenav-content></mat-sidenav-content> component in Angular Material programmatically without relyi ...

Utilize Firestore for automatic saving of data from Angular Reactive Forms

In my Angular application, I am facing an issue where data entered in a form needs to be instantly saved and updated in a Firestore database. This is crucial because multiple users will be entering data simultaneously on the same form, real-time values are ...

Modify the name of the variable when sending the object to an HTTP service in Angular version 6

export class ShopModel { public id: number; public name: string; public email: string; public phone: string; public website: string; public address: string; public gst_number: string; public pan_number: string; public ta ...

React-Redux: Unable to access the 'closed' property as it is undefined

Encountered a problem when using dispatch() in React-Redux. Specifically, the action below: export const fetchMetrics = () => { dispatch(fetchMetricsBegin); APIService.get('/dashboard/info/') .then((response) => { ...

Exploring nested static properties within TypeScript class structures

Check out this piece of code: class Hey { static a: string static b: string static c: string static setABC(a: string, b: string, c: string) { this.a = a this.b = b this.c = c return this } } class A { static prop1: Hey static ...

What is the best way to specify the type of a property that has already been assigned

I am currently utilizing a third-party library that includes a type defined as the following: export interface ThirdPartyNodeType { id: string; name: string; data: any; } Upon further exploration, I have identified the content that I intend to include ...

Input for uncomplicated changing identifier

I am looking to create types for dynamic keys that will be of type number. I have two similar types defined as follows: type UseCalculatePayments = () => { totalPayments: number; aggregate: number; condition: boolean; }; type UseCalculateCommissio ...

Get rid of the "No data" tag from the nz-table within a Simple Component

(Apologies for any language errors, English is not my native tongue) I'm working on a web page utilizing the smart and dumb components architecture. The issue I'm facing is that after fetching data from an API in my smart component, the table in ...

The TypeScript error states, "Object does not contain property 'name'."

Can someone help me with this array.map function I'm trying to use: {props.help.map((e, i) => { return <a key={i}>{e.name}</a> })} The {e} object contains keys 'name' and 'href' I keep getting an error message that ...

After closing and reopening the app, I noticed that the ionic slider images fail to display until I navigate to the next page

//// How can I retrieve the data for (let i = 0; i < res.length; i++) { let item: any = {}; item.slide = res.item(i).slide; items.push(item); } this.productsService.setSlideList = items; setTimeout(() => { this.sliderImage = items; consol ...

Can the variable name within a function be retrieved?

How can I retrieve the variable name (user_name1 or user_name2) from a sample function (GetUserName()) within itself? This variable name is required to create an object with the same name on the server side for data synchronization purposes. function GetU ...

Create Office Script calculations with quotations included

I am currently attempting to create an Excel office script formula for a cell. Are there any tips on how to insert a formula with quotes into a cell? For example, the following works fine: wsWa.getCell(WaRangeRowCount, 9).setFormula("= 1 + 1"); ...

Declaration of Typescript index.d.ts for a heavily nested function within an npm module

Regrettably, it appears that @types/rickshaw is lacking content, prompting me to create my own declaration file. The current one I have looks like this: declare module 'rickshaw' { export class Graph { constructor(obj: any); ...

Securing your Angular2 application with TypeScript for enhanced safety

Looking to create a web application using Angular2 with TypeScript. After researching authentication in Angular2, it seems I need to include the following components: index component (public) login component (public) my private component (private) Thes ...