Get 2024 Templates Mega Bundle!14 Bootstrap, Vue & React Templates + 3 Vector Sets
Get for 99$

Dropdown is not working in my Angular Metronic v8.1.5 project.


I want to use the 'app-dropdown-menu1' component in a component linked to the module I recently created. However, even though there is no error, the dropdown is not functioning. I will write the HTML file of the component and the import sections of the module file for the component I'm using. Can you help me identify where I might be making a mistake or what might be missing?


<div class="ms-1">
<!-- begin::Menu -->
<button type="button" class="
btn btn-sm btn-icon btn-color-white btn-active-white
border-0
me-n3
" [ngClass]=""btn-active-color-" + color" data-kt-menu-trigger="click"
data-kt-menu-placement="bottom-end" data-kt-menu-flip="top-end">
<span [inlineSVG]=""./assets/media/icons/duotune/general/gen024.svg""
class="svg-icon svg-icon-2"></span>
</button>
<app-dropdown-menu1></app-dropdown-menu1>
<!-- end::Menu -->
</div>



import { NgModule } from "@angular/core";
import { CommonModule } from "@angular/common";
import { RouterModule, Routes } from "@angular/router";
import { Routing } from "../pages/routing";
import { DashboardComponent } from "./dashboard.component";
import { WidgetsModule } from "../_metronic/partials/content/widgets/widgets.module";
import { InlineSVGModule } from "ng-inline-svg-2/lib_commonjs/inline-svg.module";
import { DropdownMenusModule } from "../_metronic/partials";
import { TerminalDetailComponent } from "./components/terminal-detail/terminal-detail.component";
import { NgApexchartsModule } from "ng-apexcharts";
import { NgbDropdownModule, NgbTooltipModule } from "@ng-bootstrap/ng-bootstrap";


const routes: Routes = [
{
path: "",
component: DashboardComponent,
children: Routing,
},

{
path: "dashboard/terminal/:terminalId",
component: TerminalDetailComponent,
},
];



@NgModule({
declarations: [
DashboardComponent,
TerminalDetailComponent
],
imports: [
CommonModule,
RouterModule.forChild(routes),
WidgetsModule,
DropdownMenusModule,
InlineSVGModule,
NgApexchartsModule,
NgbDropdownModule,
NgbTooltipModule

],
exports: [RouterModule]
})
export class DashboardModule { }


Text formatting options
Submit

Replies (3)


Hi,

Apologies for the delay in response.

Before delving into potential issues with your custom component or module, it's a good idea to check that the dropdown functionality works as expected in a fresh installation of Metronic. This will help determine if the issue is with your implementation or if there are any compatibility issues with the version of Metronic you're using.

Make sure you've copied all the relevant code related to the dropdown component, including HTML, and integrated it correctly into your project. Double-check any import statements or configurations related to the dropdown component in your module file to ensure they are correct.

If the dropdown works fine in a fresh installation but not in your custom component, compare your implementation with the working example from Metronic to identify any codes or missing configurations.

Feel free to provide more details or code snippets if you need further assistance.



I have performed the checks you mentioned. However, the codes for the structure I want to use in my custom component, which is also present in the subject content, are available. Is there anything missing? I am expecting concrete support from you.



Hi,

Ensure that you have imported the MenuComponent from the correct path in your project:

After importing MenuComponent, you need to initialize it in your component by calling the bootstrap() method:

MenuComponent.bootstrap();


Make sure to initialize it in the appropriate place within your component, in the ngOnInit() lifecycle hook.

Additionally, ensure that you're following the initialization pattern demonstrated in the Metronic Angular demo1 project. You can refer to the scripts-init.component.ts file in that project to see how the initialization is done.

/metronic/angular/demo1/src/app/_metronic/layout/components/scripts-init/scripts-init.component.ts

Thanks


Text formatting options
Submit
Text formatting options
Submit