Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

229
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda