NullInjectorError: R3InjectorError(ArticlesPageModule)[BarreCodeService -> BarreCodeService -> BarcodeScanner -> BarcodeScanner]: NullInjectorError: No provider for BarcodeScanner! #4628
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Description :
I need to use barre the plugin barre code scanner with the latest version of ionic (current version v7)
Steps to reproduce:
1-the scripts I used for the installation
npm install phonegap-plugin-barcodescanner
npm install @awesome-cordova-plugins/barcode-scanner
ionic cap sync
2-My code
`
import { Injectable } from '@angular/core';
import { BarcodeScanner } from '@awesome-cordova-plugins/barcode-scanner/ngx';
@Injectable({
providedIn: 'root'
})
export class BarreCodeService {
constructor(private barcodeScanner: BarcodeScanner) { }
public async getBarreCode(){
const barrecode = await this.barcodeScanner.scan()
return barrecode.text
}
}
`
First problem, i have this
NullInjectorError: R3InjectorError(ArticlesPageModule)[BarreCodeService -> BarreCodeService -> BarcodeScanner -> BarcodeScanner]: NullInjectorError: No provider for BarcodeScanner!
3- i do this in my app.module.ts
`
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { BarcodeScanner } from '@awesome-cordova-plugins/barcode-scanner/ngx';
@NgModule({
declarations: [AppComponent],
imports: [
BrowserModule,
IonicModule.forRoot(),
AppRoutingModule,
IonicStorageModule.forRoot(),
FormsModule,
ReactiveFormsModule,
BarcodeScanner
],
`
Second problem, i have this
'BarcodeScanner' does not appear to be an NgModule class.(-996002)
index.d.ts(27, 28): This likely means that the library (@awesome-cordova-plugins/barcode-scanner/ngx) which declares BarcodeScanner is not compatible with Angular Ivy. Check if a newer version of the library is available, and update if so. Also consider checking with the library's authors to see if the library is expected to be compatible with Ivy.
someone can help me please ?
Beta Was this translation helpful? Give feedback.
All reactions