Angular 12 print page example. In this tutorial, i am going to show you how to print page in angular 12 app without using any package.
Using this tutorial, you can easily implement print web page functionality in angular 12 version app using this example tutorial.
How to Print Page In Angular 12
- Step 1 – Create New Angular App
- Step 2 – Add Code on View File
- Step 3 – Add Code On app.Component ts File
- Step 4 – Start the Angular App
Step 1 – Create New Angular App
Execute the following command on it to install angular app:
ng new my-new-app
Step 2 – Add Code on View File
Create web page print in angular 12 app. So, visit src/app/ and app.component.html and update the following code into it:
<h1>Angular Print Page Example - Laratutorials.com</h1> <p> This is the page print example in angular 12:) </p> <button (click)="printPage()">print</button>
Recommended:-Google Social Login/Signin in Angular 12
Step 3 – Add Code On app.Component ts File
Go to src/app directory and open app.component.ts. Then add the following code into component.ts file:
import { Component, VERSION } from '@angular/core'; @Component({ selector: 'my-app', templateUrl: './app.component.html', styleUrls: [ './app.component.css' ] }) export class AppComponent { name = 'Angular ' + VERSION.major; printPage() { window.print(); } }
Recommended:-Angular 12 CRUD + Node.js Express + MongoDB Example
Step 4 – Start the Angular App
Execute the following command on terminal to start angular bootstrap carousel app:
ng serve
Recommended Angular Tutorials
Recommended:-Angular 12 + Node js Express + MySQL CRUD Example
Recommended:-Angular 12 Pipe Boolean to Yes or No Tutorial
Recommended:-Angular 12 ⭐ Star Rating System Tutorial
Recommended:-FullCalendar Integration in Angular 12
Recommended:-How to Export Data In Excel Sheet Using Angular 12
Recommended:-Toastr Notification in Angular 12
Recommended:-Angular 12 Dynamic Checkbox List With Reactive Form
Recommended:-Angular 12 Doughnut Chart with ng2-charts Example
Recommended:-Swiper Image Touch Slider In Angular 12
Recommended:-Convert HTML to PDF in Angular 12
Recommended:-Multiple Image Upload with Preview in Angular 12