ObaidUrRehman / ng-drag-drop

Drag & Drop for Angular - based on HTML5 with no external dependencies. :tada:
MIT License
239 stars 123 forks source link

StaticInjectorError using ng-drag-drop on Ionic3/Angular 5 project. #108

Closed vancancode closed 6 years ago

vancancode commented 6 years ago

Please remove sections that are not required.

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 /**

.HTML

  • Coffee
  • Tea
  • Milk

Am I importing it wrong or is this something caused by Angular 5 upgrade?

Hope you can help.

Thanks.

ObaidUrRehman commented 6 years ago

Can you try importing the Module with .forRoot() like this:

imports: [
NgDragDropModule.forRoot(),
IonicPageModule.forChild(LayoutPage),
],
vancancode commented 6 years ago

Thanks. That solves it.

mathiarasirangasamy commented 4 years ago

This works for me:

imports: [ NgDragDropModule.forRoot(), IonicPageModule.forChild(LayoutPage), ],