This section explains you the steps required to create a simple barcode and demonstrate the basic usage of the barcode control.
You can use Angular CLI
to setup your Angular applications.
To install Angular CLI use the following command.
npm install -g @angular/cli
Start a new Angular application using below Angular CLI command.
ng new my-app
cd my-app
All the available Essential JS 2 packages are published in npmjs.com
registry.
To install Barcode Generator component, use the following command.
npm install @syncfusion/ej2-angular-barcode-generator --save
The —save will instruct NPM to include the barcode generator package inside of the
dependencies
section of thepackage.json
.
Import Barcode Generator module into Angular application(app.module.ts) from the package @syncfusion/ej2-angular-barcode-generator
[src/app/app.module.ts].
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { BarcodeGeneratorAllModule,QRCodeGeneratorAllModule,DataMatrixGeneratorAllModule } from '@syncfusion/ej2-angular-barcode-generator';
import { AppComponent } from './app.component';
@NgModule({
//declaration of ej2-angular-Barcode Generator module into NgModule
imports: [ BrowserModule, BarcodeGeneratorAllModule, QRCodeGeneratorAllModule ,DataMatrixGeneratorAllModule ],
declarations: [ AppComponent ],
bootstrap: [ AppComponent ]
})
export class AppModule { }
You can start adding Essential JS 2 barcode-generator component to the application. To get started, add the Angular Barcode component in app.ts
and index.html
files using the following code.
import { Component } from "@angular/core";
@Component({
selector: "app-container",
// specifies the template string for the barcode generator component
template: `<ejs-barcodegenerator style="display: block;" #barcode id="barcode" width="200px" height="150px" mode="SVG" type="Codabar" value="123456789">`
})
export class AppComponent {}
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import { BarcodeGeneratorAllModule,QRCodeGeneratorAllModule,DataMatrixGeneratorAllModule } from '@syncfusion/ej2-angular-barcode-generator';
/**
* Module
*/
@NgModule({
imports: [
BrowserModule, BarcodeGeneratorAllModule, QRCodeGeneratorAllModule ,DataMatrixGeneratorAllModule
],
declarations: [AppComponent],
bootstrap: [AppComponent],
providers: [ ]
})
export class AppModule { }
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { AppModule } from './app.module';
enableProdMode();
platformBrowserDynamic().bootstrapModule(AppModule);
You can add the QR code in our Angular Barcode Generator component.
import { Component } from "@angular/core";
@Component({
selector: "app-container",
// specifies the template string for the barcode generator component
template: `<ejs-qrcodegenerator style="display: block;" #barcode id="barcode" width="200px" height="150px" mode="SVG"value="Syncfusion"></ejs-qrcodegenerator>`
})
export class AppComponent {}
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import { BarcodeGeneratorAllModule,QRCodeGeneratorAllModule,DataMatrixGeneratorAllModule } from '@syncfusion/ej2-angular-barcode-generator';
/**
* Module
*/
@NgModule({
imports: [
BrowserModule, BarcodeGeneratorAllModule, QRCodeGeneratorAllModule ,DataMatrixGeneratorAllModule
],
declarations: [AppComponent],
bootstrap: [AppComponent],
providers: [ ]
})
export class AppModule { }
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { AppModule } from './app.module';
enableProdMode();
platformBrowserDynamic().bootstrapModule(AppModule);
You can add the datamatrix code in our Angular Barcode Generator component.
import { Component } from "@angular/core";
@Component({
selector: "app-container",
// specifies the template string for the barcode generator component
template: `<ejs-datamatrixgenerator style="display: block;" #barcode id="barcode" width="200px" height="200px" mode="SVG"
type="DataMatrix" value="Syncfusion">
</ejs-datamatrixgenerator>`
})
export class AppComponent {}
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import { BarcodeGeneratorAllModule,QRCodeGeneratorAllModule,DataMatrixGeneratorAllModule } from '@syncfusion/ej2-angular-barcode-generator';
/**
* Module
*/
@NgModule({
imports: [
BrowserModule, BarcodeGeneratorAllModule, QRCodeGeneratorAllModule ,DataMatrixGeneratorAllModule
],
declarations: [AppComponent],
bootstrap: [AppComponent],
providers: [ ]
})
export class AppModule { }
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { AppModule } from './app.module';
enableProdMode();
platformBrowserDynamic().bootstrapModule(AppModule);
You can refer to our Angular Barcode Generator feature tour page for its groundbreaking feature representations. You can also explore our Angular Barcode Generator example that shows how to render the Barcode in Angular.