StaticInjectorError using ng-drag-drop on Ionic3/Angular 5 project.
vancancode opened this issue · comments
Please remove sections that are not required.
- I'm submitting a ...
[ ] bug report
[ ] feature request
[x ] other
I'm trying to use ng-drag-drop for my Ionic3/Angular5 project.
But I am experiencing this error below.
Uncaught (in promise): Error: StaticInjectorError[NgDragDropService]:
StaticInjectorError[NgDragDropService]:
NullInjectorError: No provider for NgDragDropService!
I'm new with Angular and I'm just following your instructions. I installed ng-drag-drop via NPM and I import the module like this.
import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { LayoutPage } from './layout.page';
import { NgDragDropModule } from 'ng-drag-drop'
.TS
/**
- @export
- @Class LayoutPageModule
*/
@NgModule({
declarations: [
LayoutPage,
],
imports: [
NgDragDropModule,
IonicPageModule.forChild(LayoutPage),
],
})
export class LayoutPageModule { }
.HTML
- Coffee
- Tea
- Milk
Am I importing it wrong or is this something caused by Angular 5 upgrade?
Hope you can help.
Thanks.
Can you try importing the Module with .forRoot()
like this:
imports: [
NgDragDropModule.forRoot(),
IonicPageModule.forChild(LayoutPage),
],
Thanks. That solves it.
This works for me:
imports: [
NgDragDropModule.forRoot(),
IonicPageModule.forChild(LayoutPage),
],