Closed EduhCosta closed 6 years ago
Hey, Im wondering the same thing. Any update on this topic?
Thanks
Should work out of the box with NS-Angular.
For future self :) Following code is working for me in Angular6.
// app.component.html
<Button (tap)="generateBarcode()" id="barcode" text="GENERATE BARCODE"></Button>
<Image #barcodeImg id="barcode-img" height="100" stretch="aspectFill" class="text-center"></Image>
// app.component.ts
import { Image } from "tns-core-modules/ui/image";
import { TextField } from "ui/text-field";
const ZXing = require("nativescript-zxing");
const ImageSource = require("image-source");
export class AppComponent {
@ViewChild("barcodeImg") barcodeImg: ElementRef;
barcodeText = "00381500107604446618";
...
generateBarcode() {
const barcodeImage = <Image>this.barcodeImg.nativeElement;
const zx = new ZXing();
const newImg = zx.createBarcode({
encode: this.barcodeText,
format: ZXing.CODE_128
});
barcodeImage.imageSource = ImageSource.fromNativeSource(newImg);
}
}
For future self :) Following code is working for me in Angular6.
// app.component.html <Button (tap)="generateBarcode()" id="barcode" text="GENERATE BARCODE"></Button> <Image #barcodeImg id="barcode-img" height="100" stretch="aspectFill" class="text-center"></Image> // app.component.ts import { Image } from "tns-core-modules/ui/image"; import { TextField } from "ui/text-field"; const ZXing = require("nativescript-zxing"); const ImageSource = require("image-source"); export class AppComponent { @ViewChild("barcodeImg") barcodeImg: ElementRef; barcodeText = "00381500107604446618"; ... generateBarcode() { const barcodeImage = <Image>this.barcodeImg.nativeElement; const zx = new ZXing(); const newImg = zx.createBarcode({ encode: this.barcodeText, format: ZXing.CODE_128 }); barcodeImage.imageSource = ImageSource.fromNativeSource(newImg); } }
Hi,
Can you share the project? I tried to follow the steps, but to no avail. thank you
Sorry, but this application has implementation with the angular?
Thanks