Ngx-admin: unable to insert menu module in my angular app

Created on 17 Apr 2018  路  10Comments  路  Source: akveo/ngx-admin

ERROR Error: Uncaught (in promise): Error: StaticInjectorError(AppModule)[NbMenuComponent -> NbMenuInternalService]:
StaticInjectorError(Platform: core)[NbMenuComponent -> NbMenuInternalService]:
NullInjectorError: No provider for NbMenuInternalService!
Error: StaticInjectorError(AppModule)[NbMenuComponent -> NbMenuInternalService]:
StaticInjectorError(Platform: core)[NbMenuComponent -> NbMenuInternalService]:
NullInjectorError: No provider for NbMenuInternalService!

I've imported NbModule in app.module.ts

import { NbThemeModule, NbSidebarModule, NbLayoutModule, NbSidebarService, NbMenuModule, NbMenuService } from '@nebular/theme';

imports: [
BrowserModule,
RouterModule.forRoot([
{ path: 'Login', component: LoginComponent },
{ path: 'Home', component: HomeComponent, children: [{
path: 'Dashboard', component: DashboardComponent
}]},
{ path: '', redirectTo: '/Home/Dashboard', pathMatch: 'full' },
]),
NbThemeModule.forRoot({ name: 'default' }), // this will enable the default theme, you can change this to cosmic to enable the dark theme
NbLayoutModule,
NbSidebarModule,
NbMenuModule
],
providers: [NbSidebarService, NbMenuService]

Please let me know how to resolve this issue.

Most helpful comment

Hey Guys, make sure you also imported NbMenuModule.forRoot() to the app.module, so that we can access NbMenuService in any part of the app.

All 10 comments

Hi @balajivelmurugan, please provide a complete reproducible example as it's very hard to say what's going on with this code peace.

@nnixaa Hello !

I have the same error. Could you please help me out? I can provide with any info you like.

I'm adding ngx-admin to existing project.

I've installed it from npm: npm i -S @nebular/theme

Added styles & bootstrap.

Created nb-layout with sidebars and stuff.

And when I'm inserting nb-menu to my template, it gives the same error:

core.js:1449 ERROR Error: Uncaught (in promise): Error: StaticInjectorError(AppModule)[NbMenuComponent -> NbMenuInternalService]:
StaticInjectorError(Platform: core)[NbMenuComponent -> NbMenuInternalService]:
NullInjectorError: No provider for NbMenuInternalService!
Error: StaticInjectorError(AppModule)[NbMenuComponent -> NbMenuInternalService]:
StaticInjectorError(Platform: core)[NbMenuComponent -> NbMenuInternalService]:
NullInjectorError: No provider for NbMenuInternalService!
at _NullInjector.get (core.js:1003)
at resolveToken (core.js:1301)
at tryResolveToken (core.js:1243)
at StaticInjector.get (core.js:1111)
at resolveToken (core.js:1301)
at tryResolveToken (core.js:1243)
at StaticInjector.get (core.js:1111)
at resolveNgModuleDep (core.js:10896)
at NgModuleRef_.get (core.js:12129)
at resolveDep (core.js:12619)
at _NullInjector.get (core.js:1003)
at resolveToken (core.js:1301)
at tryResolveToken (core.js:1243)
at StaticInjector.get (core.js:1111)
at resolveToken (core.js:1301)
at tryResolveToken (core.js:1243)
at StaticInjector.get (core.js:1111)
at resolveNgModuleDep (core.js:10896)
at NgModuleRef_.get (core.js:12129)
at resolveDep (core.js:12619)
at resolvePromise (zone.js:814)
at resolvePromise (zone.js:771)
at eval (zone.js:873)
at ZoneDelegate.invokeTask (zone.js:421)
at Object.onInvokeTask (core.js:4751)
at ZoneDelegate.invokeTask (zone.js:420)
at Zone.runTask (zone.js:188)
at drainMicroTaskQueue (zone.js:595)
at ZoneTask.invokeTask [as invoke] (zone.js:500)
at invokeTask (zone.js:1540)

Here is part of my app-module:

import { NbThemeModule,
NbSidebarModule, NbSidebarService,
NbLayoutModule,
NbMenuModule
} from '@nebular/theme';

@NgModule({
declarations: [
AppComponent,
LoginComponent,
RegistrationComponent,
PageNotFoundComponent,
DashboardComponent,
PasswordRecoveryComponent,
MainLogoComponent,
ForgotPasswordComponent,
// ServerErrorLoggerComponent,
ScenesComponent,
ProductionsComponent,
CharactersComponent,
EmptyComponent,
MatchValidator,
UsersComponent
],
imports: [
BrowserModule,
FormsModule,
AppRoutingModule,
HttpClientModule,
NbThemeModule.forRoot({ name: 'default' }),
NbLayoutModule, NbSidebarModule, NbMenuModule
],
providers: [
AuthService,
UserService,
ApiUrls, AppUrls, ServerCodes,
NbSidebarService, NbMenuService
],
bootstrap: [ AppComponent ]
});

Thanks in advance for help!

I'm having the same issue any time I try to use nebular in anything other than the starter kit you provide. Can you check the documentation to see if it's missing anything regarding what needs to be imported to make nb-menu recognised?

Yep, same issue when running outside the starter kit

Hey Guys, make sure you also imported NbMenuModule.forRoot() to the app.module, so that we can access NbMenuService in any part of the app.

Created an issue to track this https://github.com/akveo/nebular/issues/new

@nnixaa Worked like a charm. Thanks. Is it there in their docs?

I have to fix... in app.module.ts

providers: [NbSidebarService],

thanks

I have to fix... in app.module.ts

providers: [NbSidebarService],

thanks

you has been saved us, we are grateful

ERROR Error: Uncaught (in promise): Error: StaticInjectorError(AppModule)[NbMenuComponent -> NbMenuInternalService]:
StaticInjectorError(Platform: core)[NbMenuComponent -> NbMenuInternalService]:
NullInjectorError: No provider for NbMenuInternalService!
Error: StaticInjectorError(AppModule)[NbMenuComponent -> NbMenuInternalService]:
StaticInjectorError(Platform: core)[NbMenuComponent -> NbMenuInternalService]:
NullInjectorError: No provider for NbMenuInternalService!

I've imported NbModule in app.module.ts

import { NbThemeModule, NbSidebarModule, NbLayoutModule, NbSidebarService, NbMenuModule, NbMenuService } from '@nebular/theme';

imports: [
BrowserModule,
RouterModule.forRoot([
{ path: 'Login', component: LoginComponent },
{ path: 'Home', component: HomeComponent, children: [{
path: 'Dashboard', component: DashboardComponent
}]},
{ path: '', redirectTo: '/Home/Dashboard', pathMatch: 'full' },
]),
NbThemeModule.forRoot({ name: 'default' }), // this will enable the default theme, you can change this to cosmic to enable the dark theme
NbLayoutModule,
NbSidebarModule,
NbMenuModule
],
providers: [NbSidebarService, NbMenuService]

Please let me know how to resolve this issue.

Actually, the Error is MenuInternalService has to be called in the respective module, or if you haven't created any other module, call the service in Providers:[], it will work.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

igorls picture igorls  路  3Comments

myurAgarwal picture myurAgarwal  路  3Comments

hoswey picture hoswey  路  3Comments

Kalaijagdai picture Kalaijagdai  路  4Comments

AZm1n picture AZm1n  路  4Comments