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

262
Views
Defina metisMenu en Webpack usando angular

Creé un proyecto usando 'jhipster' y es un proyecto Angular 4 . Está utilizando Webpack e 'hilo'. Instalé metisMenu para mi requisito, está allí en el archivo package.json . metisMenu en vendor.ts y también en 'webpack' pero muestra el error jQuery(...).metisMenu is not a function .

Estoy usando Webpack por primera vez. ¿Cuál es la forma exacta de definirlo en Webpack ?

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

metisMenu directamente en el Component requerido y resolvió mi problema.

over 4 years ago · Santiago Trujillo Report

0

Gracias a Jeeten Parmar, pude resolver esto usando el siguiente código en mi componente al que hacía referencia:

 import 'metismenu'; ... // you can call this inside ngAfterViewInit() in your component jQuery('#side-menu').metisMenu();

Espero que esto ayude

over 4 years ago · Santiago Trujillo Report

0

Si usó angular cli con angular> 2 -> 4, puede declarar en .angular-cli.json así:

 "scripts": [ "../node_modules/jquery/dist/jquery.min.js", "../node_modules/metismenu/dist/metisMenu.js" [... others jquery plugin ...] ],

Y en su componente, declara jquery así:

 declare let $: any;

Debe usar ngAfterViewInit para esperar el evento "dom ready". Finalmente, tienes un componente como este:

 import {Component, ElementRef, AfterViewInit} from '@angular/core'; declare let $: any; @Component({ [...] ngAfterViewInit() { this.menuElement = this._elementRef.nativeElement.querySelector('#side-menu'); (<any>$(this.menuElement)).metisMenu(); }

tenga cuidado, si importa jquery así:

 import * as $ from 'jquery';

$ es una nueva instancia de jquery, por lo que MetisMenu no se implementará dentro y el objeto jquery se reemplaza por la nueva instancia en global

Disfrutar :)

over 4 years ago · Santiago Trujillo Report
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!