angular2-qrcode quote error NG8001:'qr-code' is not a known element:

created at 08-16-2021 views: 42

solution

If your component module is called a-demo.module, your component is called print.component.ts
Check the usage method and introduce it in the module of the current component
src\app\routes\a-demo\a-demo.module.ts

import { NgModule } from '@angular/core';
import { QRCodeModule } from 'angular2-qrcode';

...

@NgModule({
    imports: [
        QRCodeModule,
        ...
    ]
})

Instructions

src\app\routes\a-demo\print\print.component.ts

<div>
    <qr-code [value]="'All QR Code data goes here!'" [size]="150"></qr-code>
</div>

If you still report an error, check whether your component is in the current module's routing and the module is registered
src\app\routes\a-demo\a-demo-routing.module.ts

import { NgModule, Type } from '@angular/core';
import { QRCodeModule } from 'angular2-qrcode';

import { ADemoRoutingModule } from './a-demo-routing.module';
import { PrintComponent } from './print/print.component';  // Focus on observing this code, have you written

const COMPONENTS: Array<Type<void>> = [PrintComponent]; // Focus on observing this code, have you written

@NgModule({
  imports: [QRCodeModule, ADemoRoutingModule],
  declarations: COMPONENTS
})
export class ADemoModule { }

over!

created at:08-16-2021
edited at: 08-16-2021: