Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

222
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda