Problems implementing lib ng2-img-max!

0

I installed ng2-img-max for the purpose of resizing images. I want each submitted image to be resized to a predefined width and length. I see that most people use ng2-img-max when developing with 2/4 angular. I tried using this lib and then faced the following error:

Error: Uncaught (in promise): Error: No provider for Ng2PicaService

This error informs that the service name needs to be placed on the providers, the problem is that in my project I did not create any service with that name, I am guiding myself through this tutorial below;

Resizing Images in the Browser in Angular With ng2-img-max

I have created a module to store all the services related to the implementation of the image resizer as you can see below;

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { ImgMaxPXSizeService } from './img-maxpx-size.service';
import { ImgMaxSizeService } from './img-max-size.service';
import { Ng2ImgMaxService } from './ng2-img-max.service';
import { ImgExifService } from './img-exif.service';
import { Ng2PicaService } from '../../../node_modules/ng2-pica';

@NgModule({
  imports: [
    CommonModule
  ],
  declarations: [],
  providers: [
    ImgMaxPXSizeService,
    ImgExifService,
    ImgMaxSizeService,
    Ng2ImgMaxService
]
})
export class ImgMaxModule { }

//https://github.com/bergben/ng2-img-max

And the module I posted in the app.module.ts

As you can see below;

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    BrowserAnimationsModule,
    HttpModule,
    RouterModule,
    SharedModule,
    RestaurantModule,
    AdminModule,
    ImgMaxModule,// >>>>>>> modulo de imagens
    AppRoutingModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

How could I circumvent this problem?

I think that only people who have already tampered with this lib will be able to help me.

This is my complete project in the github repository.

REPOSITORY

    
asked by anonymous 09.08.2018 / 15:31

1 answer

1

You are declaring the providers, however you did not import the Ng2ImgMaxModule module as the documentation for the link you posted has been sent.

import { Ng2ImgMaxModule } from 'ng2-img-max';

@NgModule({
  declarations: [AppComponent],
  imports: [
    // ...
    Ng2ImgMaxModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule {}

Try to import this module into your ImgMaxModule .

    
09.08.2018 / 19:21