Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

123
Views
Accessing HTML loaded through Angular Component

I am showing a HTML Page loaded from my mySql Database and loading it in my angular component through .innerHTML. Looks something like this

get(): void {
this.dataServ.getMds(this.formName).subscribe((value: any) => {
  this.dataSource = value;
  this.form = '<div ng-app="formApp" ng-controller="formController">' + this.dataSource + '</div>';
}); }

With my HTML looking like this

<div [innerHtml]="form | sanitizehtml">
</div>

So I make a request to my backend, get a string back which is the entire HTML code I need. Then load it into my angular and then show it through innerHTML. So far so good but when trying to get values from the HTML code or trying to call a function it doesn't seem to get to Angular and just tells me the function is not defined.

Part of the HTML I am loading with the function "onChange" being called at onclick

<input type="checkbox" id="boxal" name="test1" [checked]="select" onclick="onChange()" (click)="onChange()">

The function in my angular component I am trying to call:

  onChange() {
console.log("TEST")}

Chrome console puts out:

blank:1 Uncaught ReferenceError: onChange is not defined at HTMLInputElement.onclick

My goal would be to be able to dynamically load a HTML form into my angular component and then get the values from the filled out form back.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!