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

225
Views
Property of function does not exist on type angular

Im trying to make a menu image execute a js function to change it's properties by adding the active class to it. I am working with angular on stackblitz and I keep getting the Property 'openbtn' does not exist on type 'HeaderComponent' error. I am lost on what to do.

The js file is in angular.json like this: "scripts": ["src/app/header/assets/js/nav.js"]

The image which should execute the function:

<img
    src="https://myimage.png"
    width="32"
    alt="!"
    class="burger"
    id="burger"
    (click)="openbtn()"
  />

The function itself:

function openbtn() {
  document.getElementById('burger').onclick = function () {
    this.classList.toggle('active');
  };
}

header.component.ts file:

import { Component, OnInit } from '@angular/core';
declare function openbtn(): any;

@Component({
  selector: 'app-header',
  templateUrl: './header.component.html',
  styleUrls: ['./header.component.css'],
})
export class HeaderComponent implements OnInit {
  constructor() {}

  ngOnInit() {
    openbtn();
  }
}
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!