0
I installed ng2-img-max in order to resize images. I want each image sent to be resized to a predefined width and length. I see that most people use ng2-img-max when developing with angular 2/4. I tried using with that lib and then faced the following error:
Error: Uncaught (in promise): Error: No provider for Ng2PicaService
This error informs that the name of the service needs to be placed in the providers, the problem is that in my project I have not created any service with this name, I am guiding myself for this tutorial below;
Resizing Images in the Browser in Angular With ng2-img-max
I have created a module to store all services regarding 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 published in the file app.modulets.
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 get around this problem?
I think only people who have ever messed with this lib will be able to help me.
This is my complete repository project github.
tries to import Imgmaxmodule into the module that you declare its component
– Eduardo Vargas
@Eduardovargas I think that’s not the problem, the problem is the file
Ng2PicaService
– wladyband