qjon / angular2-filemanager

MIT License
15 stars 9 forks source link

Angular5.2.0, StaticInjectorError(AppModule)[HttpHandler -> Injector] #22

Open MannyDev opened 5 years ago

MannyDev commented 5 years ago

Hi qjon, I'm having trouble to make it past the dependencies. I've imported all necessary packages in my target module where I'm printing the File Manager: repository.module.ts

import {FileManagerModule, IFileManagerConfiguration} from '@rign/angular2-filemanager';
import {TranslateModule, TranslateService} from 'ng2-translate';
import {EffectsModule} from '@ngrx/effects';
import {StoreModule} from '@ngrx/store';
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
import {TreeModule} from '@rign/angular2-tree';
import {ConfirmationPopoverModule} from 'angular-confirmation-popover';
...
const fileManagerConfiguration: IFileManagerConfiguration = {
    urls: {
      foldersUrl: '/api/folder',
      filesUrl: '/api/files',
      folderMoveUrl: '/api/folder/move'
    },
    isMultiSelection: true,
    mimeTypes: ['image/jpg', 'image/jpeg', 'image/png'],
    maxFileSize: 50 * 1024,
    allowChooseMultipleFiles: true
}
...
@NgModule({
    imports: [
        BrowserAnimationsModule,
        ConfirmationPopoverModule.forRoot(),
        StoreModule.forRoot({}),
        EffectsModule.forRoot([]),
        FileManagerModule.forRoot(fileManagerConfiguration),
        TreeModule.forRoot(),
        TranslateModule.forRoot(),
    ],
...

repository.component.ts

import {FileManagerConfiguration, FileManagerDispatcherService} from '@rign/angular2-filemanager';

@Component({
    selector: 'jhi-repository',
    templateUrl: './repository.component.html'
})
export class RepositoryComponent implements OnInit, OnDestroy {

constructor (
        public fileManagerConfiguration: FileManagerConfiguration,
        private fileManagerDispatcher: FileManagerDispatcherService
    ) {

    }
public toggleMultiSelection() {
    this.fileManagerConfiguration.isMultiSelection = !this.fileManagerConfiguration.isMultiSelection;

    if (!this.fileManagerConfiguration.isMultiSelection) {
      this.fileManagerDispatcher.unSelectAllFiles();
    }
}

When I remove all FileManager... references from repository.component.ts and both lines FileManagerModule.forRoot(fileManagerConfiguration) and TreeModule.forRoot() from repository.module.ts @NgModule imports the webapp does start with the other dependencies, otherwise I'm getting this error:

app.main.ts?3881:13 Error: StaticInjectorError(EReportAppModule)[HttpHandler -> Injector]: 
  StaticInjectorError(Platform: core)[HttpHandler -> Injector]: 
    NullInjectorError: No provider for Injector!

I had to install the http library in @angular/http apart from the standard in @angular/common/http for it to work as ng2-translate needs to import the Http model and module from that location.

Right now I'm completely blocked, I'd really could use a tip.

qjon commented 5 years ago

It looks like you don't import HttpClientModuleor use HTTP over HttpClient which is recomended. Please look at the demo folder, there are two examples with BE and without.

If that not help give me more info I will try to help you.

MannyDev commented 5 years ago

Hello qjon, we couldn't make it work on our app, we had to implement ng2-tree our own way. Thanks for the quick response though, adn sorry for my belated.