Year: 2021

  • Angular 12 Reactive Form Tutorial

    Angular 12 Reactive Form Tutorial

    Hello to all, welcome to therichpost.com. In this post, I will tell you, Angular 12 Reactive Form Tutorial.

    Guys with this we will cover below things:

    1. Angular 12 Reactive Form Implelemtnation.
    2. Reactive forms validation email with valid format.
    3. Reactive form checkbox validation.
    4. Angular12 Reactive Form Responsiveness with Bootstrap 5.
    Angular 12 Reactive Form
    Angular 12 Reactive Form Tutorial
    Angular 12 Reactive Form Tutorial

    Angular12 came and if you are new then you must check below link:

    1. Angular 12 Tutorials

    Here is the code snippet and please use carefully:

    1. Very first guys, here are common basics steps to add angular 12 application on your machine and also we must have latest nodejs version(14.17.0) installed for angular 12:

    $ npm install -g @angular/cli
    
    $ ng new angularform // Set Angular 11 Application on your pc
    
    cd angularform // Go inside project folder

    2. Now run below commands to set bootstrap 5 modules into our angular 12 application for responsiveness (optional):

    npm install bootstrap@next

    3. Now friends we just need to add below code into angularform/angular.json file (optional):

    "styles": [
                  ...
                  "node_modules/bootstrap/dist/css/bootstrap.min.css"
              ],
    "scripts": [
                  ...
                   "node_modules/bootstrap/dist/js/bootstrap.min.js"
               ]


    4. Now guys we will add below code into our angularform/src/app/app.module.ts file:

    ...
    import { ReactiveFormsModule } from '@angular/forms';
    
    @NgModule({
    ...
      imports: [
       ...
        ReactiveFormsModule,
       
      ],
      providers: [],
      bootstrap: [AppComponent]
    })
    export class AppModule { }

    5. Now guys we will add below code into our angularform/src/app/app.component.ts file:

    ...
    import { FormBuilder, FormGroup, Validators } from '@angular/forms';
    
    export class AppComponent {
    ...
    //Form Validables 
    registerForm: FormGroup;
    submitted = false;
    constructor( private formBuilder: FormBuilder){}
    //Add user form actions
    get f() { return this.registerForm.controls; }
    onSubmit() {
      
      this.submitted = true;
      // stop here if form is invalid
      if (this.registerForm.invalid) {
          return;
      }
      //True if all the fields are filled
      if(this.submitted)
      {
        alert("Great!!");
      }
     
    }
      ngOnInit() {
        //Add User form validations
        this.registerForm = this.formBuilder.group({
        email: ['', [Validators.required, Validators.email]],
        password: ['', [Validators.required]],
        address: ['', [Validators.required]],
        city: ['', [Validators.required]],
        state: ['', [Validators.required]],
        zip: ['', [Validators.required]],
        checkmeout: ['', [Validators.requiredTrue]]
        });
      }
    }

    6. Finally we will add below code into our angularform/src/app/app.component.html file:

    <div class="container p-5">
      <h1 class="mt-2 mb-5 text-center">Angular 12 Reactive Form Tutorial</h1>
      <form class="row g-3" [formGroup]="registerForm" (ngSubmit)="onSubmit()">
        <div class="col-md-6">
          <label for="inputEmail4" class="form-label">Email</label>
          <input type="email" formControlName="email" class="form-control" [ngClass]="{ 'is-invalid': submitted && f.email.errors }"  id="inputEmail4">
          <div *ngIf="submitted && f.email.errors" class="invalid-feedback">
            <div *ngIf="f.email.errors.required">Email is required</div>
            <div *ngIf="f.email.errors.email">Email must be a valid email address</div>
         </div>
        </div>
        <div class="col-md-6">
          <label for="inputPassword4" class="form-label">Password</label>
          <input type="password" formControlName="password" class="form-control" [ngClass]="{ 'is-invalid': submitted && f.password.errors }" id="inputPassword4">
          <div *ngIf="submitted && f.password.errors" class="invalid-feedback">
            <div *ngIf="f.password.errors.required">Password is required</div>
         </div>
        </div>
        <div class="col-12">
          <label for="inputAddress" class="form-label">Address</label>
          <input type="text" formControlName="address" class="form-control" [ngClass]="{ 'is-invalid': submitted && f.address.errors }" id="inputAddress" placeholder="1234 Main St">
          <div *ngIf="submitted && f.address.errors" class="invalid-feedback">
            <div *ngIf="f.address.errors.required">Password is required</div>
         </div>
        </div>
        <div class="col-md-6">
          <label for="inputCity" class="form-label">City</label>
          <input placeholder="Ludhiana" type="text" formControlName="city" class="form-control" [ngClass]="{ 'is-invalid': submitted && f.city.errors }" id="inputCity">
          <div *ngIf="submitted && f.city.errors" class="invalid-feedback">
            <div *ngIf="f.city.errors.required">City is required</div>
         </div>
        </div>
        <div class="col-md-4">
          <label for="inputState" class="form-label">State</label>
          <select id="inputState" class="form-select" formControlName="state" [ngClass]="{ 'is-invalid': submitted && f.state.errors }">
            <option value="">Choose...</option>
            <option value="punjab">Punjab</option>
          </select>
          <div *ngIf="submitted && f.state.errors" class="invalid-feedback">
            <div *ngIf="f.state.errors.required">State is required</div>
         </div>
        </div>
        <div class="col-md-2">
          <label for="inputZip" class="form-label">Zip</label>
          <input type="text" formControlName="zip" class="form-control" [ngClass]="{ 'is-invalid': submitted && f.zip.errors }" id="inputZip">
          <div *ngIf="submitted && f.zip.errors" class="invalid-feedback">
            <div *ngIf="f.zip.errors.required">State is required</div>
         </div>
        </div>
        <div class="col-12">
          <div class="form-check">
            <input value="" class="form-check-input" formControlName="checkmeout" [ngClass]="{ 'is-invalid': submitted && f.checkmeout.errors }" id="inputZip" type="checkbox" id="gridCheck">
            <label class="form-check-label" for="gridCheck">
              Check me out
            </label>
            <div *ngIf="submitted && f.checkmeout.errors" class="invalid-feedback">
              <div *ngIf="f.checkmeout.errors.required">This is required</div>
           </div>
          </div>
        </div>
        <div class="col-12">
          <button type="submit" class="btn btn-primary">Sign in</button>
        </div>
      </form>
    </div>

    Now we are done friends and please run ng serve command to check the output in browser(locahost:4200) and if you have any kind of query then please do comment below.

    Note: Friends, I just tell the basic setup and things, you can change the code according to your requirements. For better understanding please watch video above.

    Guys I will appreciate that if you will tell your views for this post. Nothing matters if your views will be good or bad.

    Jassa

    Thanks

  • Angular 12 Free Responsive Template Download

    Angular 12 Free Responsive Template Download

    Hello friends, welcome back to my blog. Today this blog post will tell you, Angular 12 Free Responsive Template Download.

    In this post, guys we will cover below things:

    • Bootstrap 5 Angular 12 Free Template Creation.
    • Angular 12 Bootstrap 5 Responsive Navbar.

    Angular Bootstrap Responsive Template

    Angular 12 Free Responsive Template Download
    Angular 12 Free Responsive Template Download

    Angular12 came and Bootstrap5 also and if you are new then you must check below two links:

    1. Angular12 Basic Tutorials
    2. Bootstrap 5

    Friends now I proceed onwards and here is the working code snippet and please use carefully this to avoid the mistakes:

    1. Firstly friends we need fresh angular 12 setup and for this we need to run below commands but if you already have angular 12 setup then you can avoid below commands. Secondly we should also have latest node version installed on our system:

    npm install -g @angular/cli 
    
    ng new angularboot5 //Create new Angular Project
    
    cd angularboot5 // Go inside the Angular Project Folder

    2. Now friends we need to run below commands into our project terminal to install bootstrap 5 modules into our angular application:

    npm install bootstrap@next

    3. Now friends we just need to add below code into angularboot5/src/app/app.component.html file to get final out on the web browser:

      <!-- navbar starts -->
      <nav class="navbar navbar-expand-md navbar-dark fixed-top bg-dark">
        <div class="container">
          <a class="navbar-brand" href="https://www.therichpost.com/"> <h3 class="mb-0"><i class="fas fa-fire-alt"></i></h3></a>
          <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
          </button>
          <div class="collapse navbar-collapse" id="navbarSupportedContent">
            <ul class="navbar-nav me-auto">
              <li class="nav-item">
                <a class="nav-link p-2 font-weight-bold text-white" href="#">Home </a>
              </li>
              <li class="nav-item">
                <a class="nav-link p-2 font-weight-bold text-white" href="#">Products</a>
              </li>
              <li class="nav-item">
                <a class="nav-link font-weight-bold p-2 text-white" href="#">Blog</a>
              </li>
             
            </ul>
          
           <a class="nav-link text-white p-2 font-weight-bold" href="#">Login</a> 
            <a class="nav-link text-white p-2 font-weight-bold" href="#">Register</a>
        
          </div>
          </div>
        </nav>
    <!-- nav bar ends -->
        
      <div class="jumbotron-odi-hero bg-primary">
      <div class="jumbotron-overlay">
          <div class="container jumbotron-padding  text-center">
          <h1 class="display-4">Speed up your development with high quality themes.</h1>
             <p>
                <a href="https://www.therichpost.com" class="btn btn-lg btn-success btn-circle my-4 mr-3">Visit for more</a>
             </p>
          </div>
        </div>
    </div>
    
    
             <div class="container mt-5" id="about">
                       <h1 class="text-center py-4">Why to choose fixr landing</h1>
                      
                      <div class="row text-center mt-5">
                       <div class="col-md-3 mb-2">
                        <div class="card shadow">
                          <div class="card-body">
                          <div class="py-3 text-center"> <i class="fas fa-rocket card-img-top fa-4x text-primary" aria-hidden="true"></i></div>
                          <div class="card-body">
                            <h4 class="card-title">Ready to ship</h4>
                            <p class="card-text">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
                           </div>
                          </div>
                        </div>
                        </div>
                          <div class="col-md-3 mb-2">
                         <div class="card shadow">
                          <div class="card-body">
                           <div class="py-3 text-center"><i class="fas fa-feather card-img-top fa-4x text-primary" aria-hidden="true"></i></div>
                          <div class="card-body">
                            <h4 class="card-title">Light weight</h4>
                            <p class="card-text">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
                           </div>
                          </div>
                        </div>
                        </div>
                          <div class="col-md-3 mb-2">
                         <div class="card shadow">
                          <div class="card-body">
                          <div class="py-3 text-center"><i class="fa fa-tablet card-img-top fa-4x text-primary" aria-hidden="true"></i></div>
                         
                          <div class="card-body">
                            <h4 class="card-title">Responsive </h4>
                            <p class="card-text">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
                            </div>
                          </div>
                        </div>
                        </div>
    
                                 
                        <div class="col-md-3 mb-2">
                         <div class="card shadow">
                          <div class="card-body">
                          <div class="py-3 text-center"><i class="fas fa-charging-station card-img-top fa-4x text-primary" aria-hidden="true"></i>
                         </div>
                          <div class="card-body">
                            <h4 class="card-title">Easy customisation</h4>
                            <p class="card-text">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. </p>
                            </div>
                          </div>
    
                        </div>
                        </div>
                       
                      </div>
                    </div>
                  <div class="container mt-5  text-center">
                     <p class="pt-5 pb-2 h4 text-monospace">Speed up your development with high quality themes.</p>
                    <div class="row">
                     
                      <div class="mx-auto" style="width: 800px;">
                        <p class="text-center"> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
                      </div>
                      </div>
    
                    </div>
                
                  <!-- price plan starts -->
                 <div class="container mt-5">
                    <div class="row py-5">
                      <div class="col-md-4">
                        <strong class="d-inline-block mb-2 text-primary">Price plans</strong>
                        <h3 class="mb-0">
                          No hidden charges
                       </h3>
                       <p class="lead text-muted">We have best suitable plans for your bussiness needs.Money back guarantee.</p>
                        <button type="button" class="btn btn-lg btn-primary btn-circle mb-2">Get started</button>
                      </div>
                      <div class="col-md-8">
    <div class="row text-center">
                        
                      <div class="col-md-4 mb-2">
                        <div class="card shadow">
                        <div class="card-body">
                          <h3 class="my-3 font-weight-norma text-uppercase">Free</h3>
                         
                          <span class="d-block  text-primary">
                            <span class="align-top">$</span>
                            <span class="display-4 font-weight-bold">0</span>
                            <span class="text-muted">/month</span>
                          </span>
                          <ul class="list-unstyled mt-3 mb-4">
                            <li>10 users included</li>
                            <li>2 GB of storage</li>
                            <li>Email support</li>
                            <li>Help center access</li>
                          </ul>
                          <button type="button" class="btn btn-lg btn-block btn-outline-primary btn-circle">Sign up for free</button>
                        </div>
                      </div>
                    </div>
                      <div class="col-md-4 mb-2">
                       <div class="card shadow">
                        <div class="card-body">
                           <h3 class="my-3 font-weight-norma text-uppercase">Pro</h3>
                           <span class="d-block  text-primary">
                            <span class="align-top">$</span>
                            <span class="display-4 font-weight-bold">19</span>
                            <span class="text-muted">/month</span>
                          </span>
                          <ul class="list-unstyled mt-3 mb-4">
                            <li>20 users included</li>
                            <li>10 GB of storage</li>
                            <li>Priority email support</li>
                            <li>Help center access</li>
                          </ul>
                          <button type="button" class="btn btn-lg btn-block btn-primary btn-circle">Get started</button>
                        </div>
                      </div>
                    </div>
                      <div class="col-md-4 mb-2">
                        <div class="card shadow">
                          <div class="card-body">
                           <h3 class="my-3 font-weight-norma text-uppercase">Enterprise</h3>
                           <span class="d-block  text-primary">
                            <span class="align-top">$</span>
                            <span class="display-4 font-weight-bold">199</span>
                            <span class="text-muted">/month</span>
                          </span>
                          <ul class="list-unstyled mt-3 mb-4">
                            <li>30 users included</li>
                            <li>15 GB of storage</li>
                            <li>Phone and email support</li>
                            <li>Help center access</li>
                          </ul>
                          <button type="button" class="btn btn-lg btn-block btn-primary btn-circle">Contact us</button>
                        </div>
                      </div>
                      </div>
                    </div>
                    </div>
                  
                 </div>
               </div>
                 <!-- price plan ends -->
               <!-- features start -->
                 <div class="container mt-5 ">
                       <p class="py-4 h3 text-center">Template features</p>
                      <div class="row">
                        <div class="col-md-6">
                          <div class="card shadow">
                            <div class="card-body">
                              <div class="media">
                                <div class="mr-4" style="height:64px;width:64px;">
                                  <i class="fa fa-rocket card-img-top fa-4x text-primary" aria-hidden="true"></i>
                                </div>
                                <div class="media-body">
                                  <h4 class="mt-0 tex-dark">Ready to ship</h4>
                                  <p class=" text-secondary">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
                                </div>
                              </div>
                            </div>
                          </div>
                        </div>
                        <div class="col-md-6">
                          <div class="card shadow">
                            <div class="card-body">
                              <div class="media">
                                <div class="mr-4" style="height:64px;width:64px;">
                                  <i class="fa fa-leaf card-img-top fa-4x text-primary" aria-hidden="true"></i>
                                </div>
                                <div class="media-body">
                                  <h4 class="mt-0 tex-dark">Light weight</h4>
                                  <p class=" text-secondary">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
                                </div>
                              </div>
                            </div>
                          </div>
                        </div>
                      </div>
                        <div class="row py-4">
                        <div class="col-md-6">
                          <div class="card shadow">
                            <div class="card-body">
                              <div class="media">
                                <div class="mr-4" style="height:64px;width:64px;">
                                  <i class="fa fa-tablet card-img-top fa-4x text-primary" aria-hidden="true"></i>
                                </div>
                                <div class="media-body">
                                  <h4 class="mt-0 tex-dark">Responsive</h4>
                                  <p class=" text-secondary">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
                                </div>
                              </div>
                            </div>
                          </div>
                        </div>
                        <div class="col-md-6">
                          <div class="card shadow">
                            <div class="card-body">
                              <div class="media">
                                <div class="mr-4" style="height:64px;width:64px;">
                                  <i class="fa fa-cogs card-img-top fa-4x text-primary" aria-hidden="true"></i>
                                </div>
                                <div class="media-body">
                                  <h4 class="mt-0 tex-dark">Easy customisation</h4>
                                  <p class=" text-secondary">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
                                </div>
                              </div>
                            </div>
                          </div>
                        </div>
                      </div>
                      
                  </div>
                  <!-- features end -->
             <!-- blog post start -->    
                <div class="container mt-5">
                       <h3 class="pt-4 d-inline latest-news me-2">Latest News</h3>
                      
                        <a href="" class="btn btn-outline-primary btn-circle d-inline float-right">View all</a>
                      <!--  <p class="h5 text-center text-muted">Awesome featured templates</p> -->
                      <div class="row mt-5">
                      <div class="col-md-4">
                  <div class="card mb-4 shadow-sm">
                    <img class="card-img-top img-fluid" src="https://therichpost.com/wp-content/uploads/2021/04/How-to-add-bootstrap-5-in-angular-11-application.png"  alt="">
                    <div class="card-body">
                      <h4 class="card-title mb-3 text-dark">
                      <a href="https://therichpost.com/angular-12-bootstrap-5-free-responsive-template/" class="text-decoration-none text-dark font-weight-bold">
                        Title of a blog post
                      </a>
                    </h4>
                      <p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. </p>
                      
                    </div>
                     <div class="card-footer text-muted border-0 bg-white">
                       
                      </div>
                  </div>
                </div>
                <div class="col-md-4">
                 <div class="card mb-4 shadow-sm">
                    <img class="card-img-top img-fluid" src="https://therichpost.com/wp-content/uploads/2021/04/How-to-add-bootstrap-5-in-angular-11-application.png"  alt="">
                    <div class="card-body">
                      <h4 class="card-title mb-3 text-dark">
                        <a href="https://therichpost.com/how-to-add-bootstrap-5-in-angular-12-application/" class="text-decoration-none text-dark font-weight-bold">
                        Angular 12 Responsive templates
                      </a>
                      </h4>
                      <p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. </p>
                      
                    </div>
                     <div class="card-footer text-muted border-0 bg-white">
                        
                      </div>
                  </div>
                </div>
                <div class="col-md-4">
                 <div class="card mb-4 shadow-sm">
                    <img class="card-img-top img-fluid" src="https://therichpost.com/wp-content/uploads/2021/04/How-to-add-bootstrap-5-in-angular-11-application.png"  alt="">
                    <div class="card-body">
                      <h4 class="card-title mb-3 text-dark">
                        <a href="https://therichpost.com/angular-12-ecommerce-template-free-download/" class="text-decoration-none text-dark font-weight-bold">
                       Angular 12 Free templates
                      </a>
                      </h4>
                      <p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. </p>
                      
                    </div>
                     <div class="card-footer text-muted border-0 bg-white">
                       
                      </div>
                  </div>
                </div>
        </div>
    </div>
    <!-- blog post end -->
    <!-- footer start -->
        <footer class="bg-dark text-light py-5 mt-5">
                    <div class="container">
                        <div class="row">
                            <div class="col-12 col-md-3">
                                <h3>Therichpost</h3>
                                <small class="d-block text-muted">© 2021-2022</small>
                                <small class="text-muted">All Rights Reserved.</small>
                            </div>
                            <!--end of col-->
                            <div class="col-12 col-md-9">
                                
                                <div class="row no-gutters">
                                    <div class="col-6 col-lg-3">
                                         <h5>Features</h5>
                                        <ul class="list-unstyled">
                                            <li>
                                                <a href="#" class="text-muted">Ready to ship</a>
                                            </li>
                                            <li>
                                                <a href="#" class="text-muted">Light weight</a>
                                            </li>
                                            <li>
                                                <a href="#" class="text-muted"> Responsive</a>
                                            </li>
                                            <li>
                                                <a href="#" class="text-muted">Inner Pages</a>
                                            </li>
                                        </ul>
                                    </div>
                                    <!--end of col-->
                                    <div class="col-6 col-lg-3">
                                        <h5>Resources</h5>
                                        <ul class="list-unstyled">
                                            <li>
                                                <a href="#" class="text-muted">Angular</a>
                                            </li>
                                            <li>
                                                <a href="#" class="text-muted">Java</a>
                                            </li>
                                            <li>
                                                <a href="#" class="text-muted">Camunda API</a>
                                            </li>
                                            <li>
                                                <a href="#" class="text-muted">Postman</a>
                                            </li>
                                        </ul>
                                    </div>
                                    <!--end of col-->
                                    <div class="col-6 col-lg-3">
                                         <h5>Help</h5>
                                        <ul class="list-unstyled">
                                            <li>
                                                <a href="#" class="text-muted">Forum</a>
                                            </li>
                                            <li>
                                                <a href="#" class="text-muted">FAQ</a>
                                            </li>
                                            <li>
                                                <a href="#" class="text-muted">Projects</a>
                                            </li>
                                            <li>
                                                <a href="#" class="text-muted">Site map</a>
                                            </li>
                                        </ul>
                                    </div>
                                    <!--end of col-->
                                    <div class="col-6 col-lg-3">
                                        <h5>About</h5>
                                        <ul class="list-unstyled">
                                            <li>
                                                <a href="#" class="text-muted">Team</a>
                                            </li>
                                            <li>
                                                <a href="#" class="text-muted">Privact</a>
                                            </li>
                                            <li>
                                                <a href="#" class="text-muted">Terms</a>
                                            </li>
                                            <li>
                                                <a href="#" class="text-muted">Investment</a>
                                            </li>
                                        </ul>
                                    </div>
                                    <!--end of col-->
                                </div>
                                <!--end of row-->
                            </div>
                            <!--end of col-->
                        </div>
                        <!--end of row-->
                    </div>
                    <!--end of container-->
                </footer>
    <!-- footer end -->

    4. Now friends we just need to add below code into angularboot5/angular.json file:

    "styles": [
                  ...
                  "node_modules/bootstrap/dist/css/bootstrap.min.css"
              ],
    "scripts": [
                  ...
                   "node_modules/bootstrap/dist/js/bootstrap.min.js"
               ]

    5. Now friends we just need to add below code into angularboot5/src/app/app.component.css file to add custom styles:

    .jumbotron-odi-hero{
    padding: 0rem 0rem;
     position: relative;
     max-width: 100%;
     
    }
    .jumbotron-odi-dark{
     max-width: 100%;
     padding: 0px;
     
    }
    
    .jumbotron-overlay {
     height:100%;
     padding: 100px 0;
     color:#fff;
     
    }
    .jumbotron-padding{
     padding-top: 6rem;
     
    }
    
    .btn-circle {
       border-radius: 30px;
    }
    
    .latest-news {
     border-bottom: .25rem solid transparent;
     border-bottom-color: #007bff;
    }
    a{
      text-decoration: none!important;
    }

    6. Now friends we just need to add below code into angularboot5/src/index.html file to add fontawesome icons:

    <!DOCTYPE html>
    <html lang="">
      <head>
       ...
       <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.8.2/css/all.css" rel="stylesheet" type="text/css">
     
      </head>
    ...

    Friends in the end must run ng serve command into your terminal to run the angular 12 project (localhost:4200).

    Guys click here to check the Angular 12 Bootstrap 5 Free Templates.

    Now we are done friends. If you have any kind of query, suggestion and new requirement then feel free to comment below.

    Note: Friends, In this post, I just tell the basic setup and things, you can change the code according to your requirements.

    I will appreciate that if you will tell your views for this post. Nothing matters if your views will be good or bad because with your views, I will make my next posts more good and helpful.

    Jassa

    Thanks

  • Angular 16 GraphQL Tutorial – Fetching Data

    Angular 16 GraphQL Tutorial – Fetching Data

    Hello to all, welcome to therichpost.com. In this post, I will tell you, Angular 12 GraphQL Tutorial – Fetching Data.

    Angular 12 GraphQL
    Angular 16 GraphQL Tutorial - Fetching Data
    Angular 16 GraphQL Tutorial – Fetching Data

    Angular 16 came and if you are new then you must check below link:

    1. Angular 16 Tutorials

    Here is the code snippet and please use carefully:

    1. Very first guys, here are common basics steps to add angular 16 application on your machine and also we must have latest nodejs version installed for angular 16:

    $ npm install -g @angular/cli
    
    $ ng new angulargql // Set Angular 16 Application on your pc
    
    cd angulargql // Go inside project folder

    2. Now run below commands to set graphql modules into our angular 12 application:

    ng add apollo-angular

    3. Guys after run above apollo angular command, you need to add the graphql endpoint url(please see below image) and after command execution you see `graphql.module.ts` file inside angulargql/src/app folder.

    Graphql endpoint url
    Need to add Graphql endpoint url

    4. Guy’s now we need to add below code inside our angulargql/src/app/app.component.ts file:

    ...
    import { Apollo, QueryRef } from 'apollo-angular';
    import gql from 'graphql-tag';
    
    export class AppComponent {
      ...
      
      stations: any[] = [];
    
      private query: QueryRef<any>;
    
      constructor(private apollo: Apollo) {}
    
      ngOnInit() {
        this.query = this.apollo.watchQuery({
          query: STATIONS_QUERY,
          variables: {}
        });
    
        this.query.valueChanges.subscribe(result => {
          this.stations = result.data && result.data.stations;
        });
      }
    }
    const STATIONS_QUERY = gql`
      query {
        stations {
          name
          station_id
          availability{
              num_bikes_available
              num_docks_available
      }
    }
      }
    `;

    5. Guy’s now we need to add below code inside our angulargql/src/app/app.component.html file:

    <h1>Therichpost.com</h1>
    
      <table class="table table-striped table-hover table-bordered">
        <thead>
          <tr>
            <th scope="col">ID</th>
            <th scope="col">Station Name</th>
          
          </tr>
        </thead>
        <tbody>
          <tr *ngFor="let station of stations">
            <th scope="row">{{ station.station_id }}</th>
            <td>{{ station.name }}</td>
          
           
            
          </tr>
         
        </tbody>
      </table>

    Now we are done friends and please run ng serve command to check the output in browser(locahost:4200) and if you have any kind of query then please do comment below.

    Note: Friends, I just tell the basic setup and things, you can change the code according to your requirements. For better understanding must watch video above.

    I will appreciate that if you will tell your views for this post. Nothing matters if your views will be good or bad.

    Jassa

    Thanks

  • Angular 17 Firebase Crud Tutorial

    Angular 17 Firebase Crud Tutorial

    Hello friends, welcome back to my blog. Today in this blog post, I am going to tell you, Angular 17 Firebase Crud Tutorial.

    Guy’s with this post, we will cover below things:

    1. Angular17 Firebase Curd.
    2. Angular17 Reactive Forms.
    3. Angular17 Routing.
    4. Angular17 Toast Notifications.
    Angular 16 Firebase Crud Working Video
    Angular 12 Crud Firebase Database
    Angular 12 Crud Firebase Database
    Firebase Student List
    Firebase Student List
    Firebase Realtime Database
    Firebase Realtime Database

    Guys here is video to create database in firebase:

    Create Database in Firebase

    Guys Angular 17 came and if you are new in Angular then please check below link for more tutorials:

    1. Angular 17 Tutorials

    Guys here is the code snippet and please use carefully:

    1. Firstly friends we need fresh angular 17 setup and for this we need to run below commands but if you already have angular 17 setup then you can avoid below commands. Secondly we should also have latest node version installed on our system:

    npm install -g @angular/cli //Setup Angular17 atmosphere
    
    ng new angularcrud //Install New Angular App
    
    /**You need to update your Nodejs also for this verison**/
    
    cd angularcrud //Go inside the Angular 17 Project

    2. Now guy’s we need to run below commands inside our angular 17 project to install firebase , bootstrap, toast modules or guys you can add according to your needs:

    npm install bootstrap --save
    
    npm i @fortawesome/fontawesome-free
    
    npm install firebase @angular/fire --save
    
    npm install ngx-toastr --save
    
    npm install @angular/animations --save
    
    npm install ngx-pagination --save

    3. Now guy’s we need to run below commands into our angular project to create add, update and listing components:

    ng g c add-student
    
    ng g c edit-student
    
    ng g c student-list

    4. After run the above create component commands, we will see new folders into our app folder:

    angular created components
    angular created components

    5. Now add below code into our angularcrud/angular.json file:

    "styles": [
                  ...
                  "node_modules/bootstrap/dist/css/bootstrap.min.css",
                  "node_modules/@fortawesome/fontawesome-free/css/all.css",
                  "node_modules/ngx-toastr/toastr.css"
                ],

    6. Now guy’s we need to add firebase configuration details that I have shown in my second video(create database on firebase) and  we need to add that details in angularcrud/src/environments/environment.ts file:

    export const environment = {
      production: false,
        firebaseConfig : {
        apiKey: "***",
        authDomain: "***",
        databaseURL: "***",
        projectId: "***",
        storageBucket: "***",
        messagingSenderId: "***",
        appId: "***",
        measurementId: "***"
      }
    };

    7. Now guy’s we nee to add or replace below code into our angularcrud/src/app/app.module.ts file:

    import { BrowserModule } from '@angular/platform-browser';
    import { NgModule } from '@angular/core';
    import { AngularFireModule } from '@angular/fire';
    import { AngularFireDatabaseModule } from '@angular/fire/database';
    import { AngularFirestoreModule } from '@angular/fire/firestore';
    import { AppComponent } from './app.component';
    import { environment } from 'src/environments/environment';
    import { AddStudentComponent } from './add-student/add-student.component';
    import { StudentListComponent } from './student-list/student-list.component';
    import { EditStudentComponent } from './edit-student/edit-student.component';
    import { FormsModule, ReactiveFormsModule } from '@angular/forms';
    import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
    // NGX Pagination
    import { NgxPaginationModule } from 'ngx-pagination';
    import { ToastrModule } from 'ngx-toastr';
    import { RouterModule, Routes } from '@angular/router';
    
    // Routes array define component along with the path name for url
    const routes: Routes = [
      { path: '', redirectTo: '/register-student', pathMatch: 'full' },
      { path: 'register-student', component: AddStudentComponent },
      { path: 'view-students', component: StudentListComponent },
      { path: 'edit-student/:id', component: EditStudentComponent }
    ];
    
    @NgModule({
      declarations: [
        AppComponent,
        AddStudentComponent,
        EditStudentComponent,
        StudentListComponent
      ],
      imports: [
        BrowserModule,
        FormsModule,
        ReactiveFormsModule,
        
        AngularFireModule.initializeApp(environment.firebaseConfig),
        AngularFireDatabaseModule,
        AngularFirestoreModule,
        BrowserAnimationsModule, // required animations module
        NgxPaginationModule,
        ToastrModule.forRoot(),
        RouterModule.forRoot(routes)
      ],
      providers: [],
      bootstrap: [AppComponent]
    })
    export class AppModule { }

    8. Now guy’s we need to add below code into our angularcrud/src/app/app.component.html file:

    <!-- Top navigation -->
    <nav class="navbar navbar-dark fixed-top bg-dark flex-md-nowrap p-0 shadow p-2 mb-0">
      <a class="navbar-brand col-sm-3 col-md-2 mr-0" routerLink="/register-student">
        
        <span class="dasboard-text">Therichpost.com</span>
      </a>
      <ul class="navbar-nav px-3">
        <li class="nav-item text-nowrap">
          <a class="nav-link" routerLink="/register-student">
            Welcome Jassa
          </a>
        </li>
      </ul>
    </nav>
    
    <!-- Sidebar navigation -->
    <div class="container-fluid">
      <div class="row">
        <nav class="col-md-2 d-md-block bg-light sidebar vh-100" style="margin-top: 60px;">
          <div class="sidebar-sticky">
            <ul class="nav flex-column">
    
              <!-- routerLink="/register-student" to navigate to view-students component -->
              <li class="nav-item">
                <a class="nav-link" routerLink="/register-student" routerLinkActive="active">
                  <i class="fas fa-plus"></i>Add Student
                </a>
              </li>
    
              <!-- routerLink="/view-students" to navigate to view-students component -->
              <!-- routerLinkActive="active" activates active class for component-->
              <li class="nav-item">
                <a class="nav-link" routerLink="/view-students" routerLinkActive="active">
                  <i class="fas fa-list-ul"></i>Students List
                </a>
              </li>
            </ul>
          </div>
        </nav>
    
        <!-- Main content -->
        <main role="main" style="margin-top: 50px;" class="col-md-9 ml-sm-auto col-lg-10 px-4">
          <div class="inner-adjust">
    
            <!-- Use router template to show the components for which router service is activated -->
            <router-outlet></router-outlet>
    
          </div>
        </main>
    
      </div>
    </div>
    <div class="jumbotron text-center mb-0 fixed-bottom bg-dark text-white">
     <p>therichpost.com</p> 
    </div>

    9. First create services folder into our app folder and run below command:

    ng g s services/crud

    10. Now guy’s open angularcrud/src/app/services/crud.service.ts file and below code into it:

    import { Injectable } from '@angular/core';
    
    import { AngularFireDatabase, AngularFireList, AngularFireObject } from '@angular/fire/database';  // Firebase modules for Database, Data list and Single object
    export interface Student {
        $key: string;
        firstName: string;
        lastName: string;
        email: string
        mobileNumber: Number;
     }
    @Injectable({
      providedIn: 'root'
    })
    
    export class CrudService {
      studentsRef: AngularFireList<any>;    // Reference to Student data list, its an Observable
      studentRef: AngularFireObject<any>;   // Reference to Student object, its an Observable too
      
      // Inject AngularFireDatabase Dependency in Constructor
      constructor(private db: AngularFireDatabase) { }
    
      // Create Student
      AddStudent(student: Student) {
        this.studentsRef.push({
          firstName: student.firstName,
          lastName: student.lastName,
          email: student.email,
          mobileNumber: student.mobileNumber
        })
      }
    
      // Fetch Single Student Object
      GetStudent(id: string) {
        this.studentRef = this.db.object('students-list/' + id);
        return this.studentRef;
      }
    
      // Fetch Students List
      GetStudentsList() {
        this.studentsRef = this.db.list('students-list');
        return this.studentsRef;
      }  
    
      // Update Student Object
      UpdateStudent(student: Student) {
        this.studentRef.update({
          firstName: student.firstName,
          lastName: student.lastName,
          email: student.email,
          mobileNumber: student.mobileNumber
        })
      }  
    
      // Delete Student Object
      DeleteStudent(id: string) { 
        this.studentRef = this.db.object('students-list/'+id);
        this.studentRef.remove();
      }
      
    }

    11. Now guy’s open angularcrud/src/app/add-student/add-student.component.ts file and add below code into it:

    import { Component, OnInit } from '@angular/core';
    import { CrudService } from '../services/crud.service';    // CRUD services API
    import { FormBuilder, FormGroup, FormControl, Validators } from '@angular/forms'; // Reactive form services
    import { ToastrService } from 'ngx-toastr'; // Alert message using NGX toastr
    
    
    @Component({
      selector: 'app-add-student',
      templateUrl: './add-student.component.html',
      styleUrls: ['./add-student.component.css']
    })
    
    export class AddStudentComponent implements OnInit {
      
      public studentForm: FormGroup;  // Define FormGroup to student's form
     
      constructor(
        public crudApi: CrudService,  // CRUD API services
        public fb: FormBuilder,       // Form Builder service for Reactive forms
        public toastr: ToastrService  // Toastr service for alert message
      ) { }
    
     
      ngOnInit() {
        this.crudApi.GetStudentsList();  // Call GetStudentsList() before main form is being called
        this.studenForm();              // Call student form when component is ready
      }
    
      // Reactive student form
      studenForm() {
        this.studentForm = this.fb.group({
          firstName: ['', [Validators.required, Validators.minLength(2)]],
          lastName: [''],
          email: ['', [Validators.required, Validators.pattern('^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+.[a-zA-Z0-9-.]+
    

    12. Now open angularcrud/src/app/add-student/add-student.component.html file and add below code into it:

    <div class="pt-3 pb-2 mb-3 border-bottom">
        <h1 class="h2">Add Student</h1>
        <p class="custom-text">A demo CRUD  for <strong>student management system</strong> built with <strong>Angular 10
            and Firebase</strong></p>
      </div>
      
      <!-- Student form -->
      <form [formGroup]="studentForm" (ngSubmit)="submitStudentData()" novalidate>
        <div class="row">
          <div class="col-lg-5 col-md-12 col-sm-12">
            <div class="row">
      
              <div class="col-md-12 mb-3">
                <label>First name</label>
                <input type="text" formControlName="firstName" class="form-control" required>
                <!-- Showing errors using getter method -->
                <p *ngIf="firstName.touched && firstName.invalid" class="error"><sup>*</sup>Please enter atleast first name</p>
                <p *ngIf="firstName.errors?.minlength" class="error"><sup>*</sup>Name shouldn't be less than 2 words</p>
              </div>
      
              <div class="col-md-12 mb-3">
                <label>Last name</label>
                <input type="text" formControlName="lastName" class="form-control">
              </div>
      
            </div>
      
            <div class="row">
              <div class="col-md-12 mb-3">
                <label>Email</label>
                <input type="email" formControlName="email" class="form-control" required>
                <!-- Showing errors using getter method -->
                <p *ngIf="email.touched && email.invalid" class="error"><sup>*</sup>Please provide email</p>
                <p *ngIf="email.errors?.pattern" class="error"><sup>*</sup>Please enter correct email</p>
              </div>
      
              <div class="col-md-12 mb-3">
                <label>Mobile number</label>
                <input type="text" formControlName="mobileNumber" class="form-control" required>
                <!-- Showing errors using getter method -->
                <p *ngIf="mobileNumber.touched && mobileNumber.invalid" class="error"><sup>*</sup>Please provide contact
                  number</p>
                <p *ngIf="mobileNumber.errors?.pattern" class="error"><sup>*</sup>Use numbers only
                  number</p>
              </div>
      
            </div>
      
            <div class="form-group text-right">
              <button type="button" class="btn btn-warning mr-2" (click)="ResetForm()">Reset</button>
              <button type="submit" class="btn btn-primary" [disabled]="!studentForm.valid">Add Student</button>
            </div>
      
          </div>
        </div>
      </form><!-- Student form ends-->

    13. Now guy’s open app/add-student/add-student.component.css file and add below code into it:

    p.error { color: red; }

    14. Now open angularcrud/src/app/edit-student/edit-student.component.ts file and add below code into it:

    import { Component, OnInit, AfterViewInit } from '@angular/core';
    import { FormGroup, FormBuilder, Validators } from '@angular/forms';
    import { CrudService } from '../services/crud.service';
    import { ActivatedRoute, Router } from "@angular/router"; // ActivatedRoue is used to get the current associated components information.
    import { Location } from '@angular/common';  // Location service is used to go back to previous component
    import { ToastrService } from 'ngx-toastr';
    
    @Component({
      selector: 'app-edit-student',
      templateUrl: './edit-student.component.html',
      styleUrls: ['./edit-student.component.css']
    })
    
    export class EditStudentComponent implements OnInit {
      editForm: FormGroup;  // Define FormGroup to student's edit form
      
      constructor(
        private crudApi: CrudService,       // Inject CRUD API in constructor
        private fb: FormBuilder,            // Inject Form Builder service for Reactive forms
        private location: Location,         // Location service to go back to previous component
        private actRoute: ActivatedRoute,   // Activated route to get the current component's inforamation
        private router: Router,             // Router service to navigate to specific component
        private toastr: ToastrService       // Toastr service for alert message
      ){ }
    
      ngOnInit() {
        this.updateStudentData();   // Call updateStudentData() as soon as the component is ready 
        const id = this.actRoute.snapshot.paramMap.get('id');  // Getting current component's id or information using ActivatedRoute service
        this.crudApi.GetStudent(id).valueChanges().subscribe(data => {
          this.editForm.setValue(data)  // Using SetValue() method, It's a ReactiveForm's API to store intial value of reactive form 
        })
      }
    
      // Accessing form control using getters
      get firstName() {
        return this.editForm.get('firstName');
      }
    
      get lastName() {
        return this.editForm.get('lastName');
      }
    
      get email() {
        return this.editForm.get('email');
      }
    
      get mobileNumber() {
        return this.editForm.get('mobileNumber');
      }  
    
      // Contains Reactive Form logic
      updateStudentData() {
        this.editForm = this.fb.group({
          firstName: ['', [Validators.required, Validators.minLength(2)]],
          lastName: [''],
          email: ['', [Validators.required, Validators.pattern('^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+.[a-zA-Z0-9-.]+
    

    15. Now open angularcrud/src/app/edit-student/edit-student.component.html file and add below code into it:

    <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
        <h1 class="h2">Edit Student Details</h1>
        <div class="btn-toolbar mb-2 mb-md-0">
           <div class="btn-group">
              <!-- goBack() methos to back to previous component -->
              <button class="btn btn-sm btn-outline-secondary" (click)="goBack()">Go Back</button>
           </div>
        </div>
     </div>
     
     
     <div class="row">
        <div class="col-lg-12">
           <div class="pricing-header form-block mx-auto">
     
              <!-- Student's Edit Form -->
              <form [formGroup]="editForm" (ngSubmit)="updateForm()" novalidate>
                 <div class="row">
                    <div class="col-lg-5 col-md-12 col-sm-12">
                       <div class="row">
                          <div class="col-md-12 mb-3">
                             <label>First name</label>
                             <input type="text" formControlName="firstName" class="form-control" required>
                             <p *ngIf="firstName.touched && firstName.invalid" class="error">
                                 <sup>*</sup>Please enter firstname
                             </p>
                             <p *ngIf="firstName.errors?.minlength" class="error">
                                 <sup>*</sup>Name shouldn't be less than 2 words
                             </p>
                          </div>
                          <div class="col-md-12 mb-3">
                             <label>Last name</label>
                             <input type="text" formControlName="lastName" class="form-control">
                          </div>
                       </div>
                       <div class="row">
                          <div class="col-md-12 mb-3">
                             <label>Email</label>
                             <input type="email" formControlName="email" class="form-control" required>
                             <p *ngIf="email.touched && email.invalid" class="error"><sup>*</sup>Please provide email</p>
                             <p *ngIf="email.errors?.pattern" class="error"><sup>*</sup>Please enter correct email</p>
                          </div>
                          <div class="col-md-12 mb-3">
                             <label>Mobile number</label>
                             <input type="text" formControlName="mobileNumber" class="form-control" required>
                             <p *ngIf="mobileNumber.touched && mobileNumber.invalid" class="error">
                                <sup>*</sup>Please provide contact number
                             </p>
                             <p *ngIf="mobileNumber.errors?.pattern" class="error">
                                <sup>*</sup>Use numbers only number
                             </p>
                          </div>
                       </div>
                       <div class="form-group text-right">
                          <button type="submit" class="btn btn-success btn-block" [disabled]="!editForm.valid">
                              Update Student
                          </button>
                       </div>
                    </div>
                 </div>
              </form>
              <!-- Student's Edit Form ends-->
              
           </div>
        </div>
     </div>

    16. Now open angularcrud/src/app/edit-student/edit-student.component.css file and add below code into it:

    p.error { color: red; }

    17. Now open angularcrud/src/app/student-list/student-list.component.ts file and add below code into it:

    import { Component, OnInit } from '@angular/core';
    import { CrudService } from '../services/crud.service';  // CRUD API service class
    import { ToastrService } from 'ngx-toastr';      // Alert message using NGX toastr
    
    export interface Student {
        $key: string;
        firstName: string;
        lastName: string;
        email: string
        mobileNumber: Number;
     }
    @Component({
      selector: 'app-student-list',
      templateUrl: './student-list.component.html',
      styleUrls: ['./student-list.component.css']
    })
    
    export class StudentListComponent implements OnInit {
      p: number = 1;                      // Settup up pagination variable
      Student: Student[];                 // Save students data in Student's array.
      hideWhenNoStudent: boolean = false; // Hide students data table when no student.
      noData: boolean = false;            // Showing No Student Message, when no student in database.
      
      
    
      constructor(
        public crudApi: CrudService, // Inject student CRUD services in constructor.
        public toastr: ToastrService // Toastr service for alert message
        ){ }
    
    
      ngOnInit() {
        this.dataState(); // Initialize student's list, when component is ready
        let s = this.crudApi.GetStudentsList(); 
        s.snapshotChanges().subscribe(data => { // Using snapshotChanges() method to retrieve list of data along with metadata($key)
          this.Student = [];
          data.forEach(item => {
            let a = item.payload.toJSON(); 
            a['$key'] = item.key;
            this.Student.push(a as Student);
          })
        })
      }
    
      // Using valueChanges() method to fetch simple list of students data. It updates the state of hideWhenNoStudent, noData variables when any changes occurs in student data list in real-time.
      dataState() {     
        this.crudApi.GetStudentsList().valueChanges().subscribe(data => {
          
          if(data.length <= 0){
            this.hideWhenNoStudent = false;
            this.noData = true;
          } else {
            this.hideWhenNoStudent = true;
            this.noData = false;
          }
        })
      }
    
      // Method to delete student object
      deleteStudent(student) {
        if (window.confirm('Are sure you want to delete this student ?')) { // Asking from user before Deleting student data.
          this.crudApi.DeleteStudent(student.$key) // Using Delete student API to delete student.
          this.toastr.success(student.firstName + ' successfully deleted!'); // Alert message will show up when student successfully deleted.
        }
      }
    
    }

    18. Now your angularcrud/src/app/student-list/student-list.component.thtml s file and add below code into it:

    <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
        <h1 class="h2">Students List</h1>
        <!-- It won't show if there is no student data -->
        <a routerLink="/register-student" class="btn btn-success" *ngIf="hideWhenNoStudent">
          <i class="fas fa-plus custom-fa-plus"></i>
          Add Student
        </a>
      </div>
      
      <div class="pricing-header mx-auto">
      
        <!-- No data shows when their is no student data available -->
        <div class="no-data text-center" *ngIf="noData">
          
          <p class="nodata-msg">No student added yet!</p>
          <a routerLink="/register-student" class="btn btn-success">
            <i class="fas fa-plus custom-fa-plus"></i>
            Add Student
          </a>
        </div>
      
        <!-- Showing students data -->
        <div class="table-responsive" *ngIf="hideWhenNoStudent">
          <table class="table table-bordered table-responsive-sm table-responsive-md table-responsive-lg">
            <thead>
              <tr>
                <th scope="col">Student Id</th>
                <th scope="col">Student name</th>
                <th scope="col">Email</th>
                <th scope="col">Mobile number</th>
                <th class="text-center" scope="col">Edit</th>
              </tr>
            </thead>
            <tbody>
              <!-- *ngFor loop iterates over Student array and fetch the student's data -->
              <!-- paginate pipe will add pagination in student's list, it won't show if items are less then 7 -->
              <tr *ngFor="let student of Student | paginate: { itemsPerPage: 7, currentPage: p }; let i = index;">
                <th scope="row">{{student.$key}}</th>
                <td>{{student.firstName}} {{student.lastName}}</td>
                <td>{{student.email}}</td>
                <td>{{student.mobileNumber}}</td>
                <td class="text-center action-block">
                  <!-- routerLink="/edit-student/{{student.$key}}" is refered to { path: 'edit-student/:id', component: EditStudentComponent } in app-routing.moudles.ts -->
                  <i class="far fa-edit" routerLink="/edit-student/{{student.$key}}"></i>
                  <i class="far fa-trash-alt" (click)="deleteStudent(student)"></i></td>
              </tr>
            </tbody>
          </table>
        </div>
        <!-- Pagination -->
        <pagination-controls (pageChange)="p = $event" autoHide="true" responsive="true"></pagination-controls>
      </div>
    )]], mobileNumber: ['', [Validators.required, Validators.pattern('^[0-9]+

    12. Now open angularcrud/src/app/add-student/add-student.component.html file and add below code into it:

    
    

    13. Now guy’s open app/add-student/add-student.component.css file and add below code into it:

    
    

    14. Now open angularcrud/src/app/edit-student/edit-student.component.ts file and add below code into it:

    
    

    15. Now open angularcrud/src/app/edit-student/edit-student.component.html file and add below code into it:

    
    

    16. Now open angularcrud/src/app/edit-student/edit-student.component.css file and add below code into it:

    
    

    17. Now open angularcrud/src/app/student-list/student-list.component.ts file and add below code into it:

    
    

    18. Now your angularcrud/src/app/student-list/student-list.component.thtml s file and add below code into it:

    
    )]]
        })  
      }
    
      // Accessing form control using getters
      get firstName() {
        return this.studentForm.get('firstName');
      }
    
      get lastName() {
        return this.studentForm.get('lastName');
      }  
    
      get email() {
        return this.studentForm.get('email');
      }
    
      get mobileNumber() {
        return this.studentForm.get('mobileNumber');
      }
    
      // Reset student form's values
      ResetForm() {
        this.studentForm.reset();
      }  
     
      submitStudentData() {
        this.crudApi.AddStudent(this.studentForm.value); // Submit student data using CRUD API
        this.toastr.success(this.studentForm.controls['firstName'].value + ' successfully added!'); // Show success message when data is successfully submited
        this.ResetForm();  // Reset form when clicked on reset button
       };
    
    }

    12. Now open angularcrud/src/app/add-student/add-student.component.html file and add below code into it:

    
    

    13. Now guy’s open app/add-student/add-student.component.css file and add below code into it:

    
    

    14. Now open angularcrud/src/app/edit-student/edit-student.component.ts file and add below code into it:

    
    

    15. Now open angularcrud/src/app/edit-student/edit-student.component.html file and add below code into it:

    
    

    16. Now open angularcrud/src/app/edit-student/edit-student.component.css file and add below code into it:

    
    

    17. Now open angularcrud/src/app/student-list/student-list.component.ts file and add below code into it:

    
    

    18. Now your angularcrud/src/app/student-list/student-list.component.thtml s file and add below code into it:

    
    )]],
          mobileNumber: ['', [Validators.required, Validators.pattern('^[0-9]+
    

    15. Now open angularcrud/src/app/edit-student/edit-student.component.html file and add below code into it:

    
    

    16. Now open angularcrud/src/app/edit-student/edit-student.component.css file and add below code into it:

    
    

    17. Now open angularcrud/src/app/student-list/student-list.component.ts file and add below code into it:

    
    

    18. Now your angularcrud/src/app/student-list/student-list.component.thtml s file and add below code into it:

    
    )]],
          mobileNumber: ['', [Validators.required, Validators.pattern('^[0-9]+
    

    12. Now open angularcrud/src/app/add-student/add-student.component.html file and add below code into it:

    
    

    13. Now guy’s open app/add-student/add-student.component.css file and add below code into it:

    
    

    14. Now open angularcrud/src/app/edit-student/edit-student.component.ts file and add below code into it:

    
    

    15. Now open angularcrud/src/app/edit-student/edit-student.component.html file and add below code into it:

    
    

    16. Now open angularcrud/src/app/edit-student/edit-student.component.css file and add below code into it:

    
    

    17. Now open angularcrud/src/app/student-list/student-list.component.ts file and add below code into it:

    
    

    18. Now your angularcrud/src/app/student-list/student-list.component.thtml s file and add below code into it:

    
    )]]
        })  
      }
    
      // Accessing form control using getters
      get firstName() {
        return this.studentForm.get('firstName');
      }
    
      get lastName() {
        return this.studentForm.get('lastName');
      }  
    
      get email() {
        return this.studentForm.get('email');
      }
    
      get mobileNumber() {
        return this.studentForm.get('mobileNumber');
      }
    
      // Reset student form's values
      ResetForm() {
        this.studentForm.reset();
      }  
     
      submitStudentData() {
        this.crudApi.AddStudent(this.studentForm.value); // Submit student data using CRUD API
        this.toastr.success(this.studentForm.controls['firstName'].value + ' successfully added!'); // Show success message when data is successfully submited
        this.ResetForm();  // Reset form when clicked on reset button
       };
    
    }

    12. Now open angularcrud/src/app/add-student/add-student.component.html file and add below code into it:

    
    

    13. Now guy’s open app/add-student/add-student.component.css file and add below code into it:

    
    

    14. Now open angularcrud/src/app/edit-student/edit-student.component.ts file and add below code into it:

    
    

    15. Now open angularcrud/src/app/edit-student/edit-student.component.html file and add below code into it:

    
    

    16. Now open angularcrud/src/app/edit-student/edit-student.component.css file and add below code into it:

    
    

    17. Now open angularcrud/src/app/student-list/student-list.component.ts file and add below code into it:

    
    

    18. Now your angularcrud/src/app/student-list/student-list.component.thtml s file and add below code into it:

    
    )]]
        })
      }
    
      // Go back to previous component
      goBack() {
        this.location.back();
      }
    
      // Below methods fire when somebody click on submit button
      updateForm(){
        this.crudApi.UpdateStudent(this.editForm.value);       // Update student data using CRUD API
        this.toastr.success(this.editForm.controls[‘firstName’].value + ‘ updated successfully’);   // Show succes message when data is successfully submited
        this.router.navigate([‘view-students’]);               // Navigate to student’s list page when student data is updated
      }
    
    }
    

    15. Now open angularcrud/src/app/edit-student/edit-student.component.html file and add below code into it:

    
    

    16. Now open angularcrud/src/app/edit-student/edit-student.component.css file and add below code into it:

    
    

    17. Now open angularcrud/src/app/student-list/student-list.component.ts file and add below code into it:

    
    

    18. Now your angularcrud/src/app/student-list/student-list.component.thtml s file and add below code into it:

    
    )]],
          mobileNumber: [”, [Validators.required, Validators.pattern(‘^[0-9]+
    

    12. Now open angularcrud/src/app/add-student/add-student.component.html file and add below code into it:

    
    

    13. Now guy’s open app/add-student/add-student.component.css file and add below code into it:

    
    

    14. Now open angularcrud/src/app/edit-student/edit-student.component.ts file and add below code into it:

    
    

    15. Now open angularcrud/src/app/edit-student/edit-student.component.html file and add below code into it:

    
    

    16. Now open angularcrud/src/app/edit-student/edit-student.component.css file and add below code into it:

    
    

    17. Now open angularcrud/src/app/student-list/student-list.component.ts file and add below code into it:

    
    

    18. Now your angularcrud/src/app/student-list/student-list.component.thtml s file and add below code into it:

    
    )]]
        })  
      }
    
      // Accessing form control using getters
      get firstName() {
        return this.studentForm.get(‘firstName’);
      }
    
      get lastName() {
        return this.studentForm.get(‘lastName’);
      }  
    
      get email() {
        return this.studentForm.get(’email’);
      }
    
      get mobileNumber() {
        return this.studentForm.get(‘mobileNumber’);
      }
    
      // Reset student form’s values
      ResetForm() {
        this.studentForm.reset();
      }  
     
      submitStudentData() {
        this.crudApi.AddStudent(this.studentForm.value); // Submit student data using CRUD API
        this.toastr.success(this.studentForm.controls[‘firstName’].value + ‘ successfully added!’); // Show success message when data is successfully submited
        this.ResetForm();  // Reset form when clicked on reset button
       };
    
    }
    

    12. Now open angularcrud/src/app/add-student/add-student.component.html file and add below code into it:

    
    

    13. Now guy’s open app/add-student/add-student.component.css file and add below code into it:

    
    

    14. Now open angularcrud/src/app/edit-student/edit-student.component.ts file and add below code into it:

    
    

    15. Now open angularcrud/src/app/edit-student/edit-student.component.html file and add below code into it:

    
    

    16. Now open angularcrud/src/app/edit-student/edit-student.component.css file and add below code into it:

    
    

    17. Now open angularcrud/src/app/student-list/student-list.component.ts file and add below code into it:

    
    

    18. Now your angularcrud/src/app/student-list/student-list.component.thtml s file and add below code into it:

    
    
    
    

    This is it and please run ng serve command check the working on browser(localhost:4200) and if you have any kind of query then please do comment below.

    Guy’s I will come with more demos related angular 17. Please share your views on this post and you views are very important to me.

    Jassa

    Thanks

  • Angular 12 Ecommerce Template Free Download

    Angular 12 Ecommerce Template Free Download

    Hello to all, welcome back to my blog. Today in this blog post, I am going to show you, Angular 12 Ecommerce Template Free Download.

    Angular 12 templates

    Angular 12 Bootstrap 5 Ecommerce Template Free Download
    Angular 12 Bootstrap 5 Ecommerce Template Free Download

    Angular12 and Bootstrap 5 came and if you are new then you must check below links:

    1. Angular12 Basic Tutorials
    2. Bootstrap 5
    3. For more Angular Free Templates click here

    Friends now I proceed onwards and here is the working code snippet and use this carefully to avoid the mistakes:

    1. Firstly friends we need fresh angular 12 setup and for this we need to run below commands but if you already have angular 12 setup then you can avoid below commands. Secondly we should also have latest node version installed on our system:

    Guys you can skip this first step if you already have angular 12 fresh setup:

    npm install -g @angular/cli 
    
    ng new angularbootstrap //Create new Angular Project
    
    cd angularbootstrap  // Go inside the Angular Project Folder
    
    ng serve --open // Run and Open the Angular Project
    
    http://localhost:4200/ // Working Angular Project Url

    2. Now friends, please download zip(in this zip file there are js, css and images for angular bootstrap template) file from below path and extract zip and please put all the zip file folders in “src/assets” folder(which we will get from zip file):

    https://therichpost.com/ng-b5.zip

    3. Now friends please add below code into angularbootstrap/src/index.html file:

    ...
    <head>
    ...
    <!-- Custom styles for this template -->
      <link href="assets/css/bootstrap.css" rel="stylesheet">
      <link href="assets/css/ui.css" rel="stylesheet">
      <link href="assets/css/responsive.css" rel="stylesheet">
      <link href="assets/css/all.min.css" rel="stylesheet">
      <script src="assets/js/bootstrap.min.js"></script>
    </head>

    4. Now friends we need to add below code into angularbootstrap/src/app/app.component.html file:

    <header class="section-header">
    
        <section class="header-main border-bottom">
            <div class="container">
        <div class="row align-items-center">
            <div class="col-lg-2 col-4">
                Therichpost.com
            </div>
            <div class="col-lg-6 col-sm-12">
                <form action="#" class="search">
                    <div class="input-group w-100">
                        <input type="text" class="form-control" placeholder="Search">
                        <div class="input-group-append">
                          <button class="btn btn-primary" type="submit">
                            <i class="fa fa-search"></i>
                          </button>
                        </div>
                    </div>
                </form> <!-- search-wrap .end// -->
            </div> <!-- col.// -->
            <div class="col-lg-4 col-sm-6 col-12">
                <div class="widgets-wrap float-md-end">
                    <div class="widget-header  me-3">
                        <a href="#" class="icon icon-sm rounded-circle border"><i class="fa fa-shopping-cart"></i></a>
                        <span class="badge badge-pill badge-danger notify">0</span>
                    </div>
                    <div class="widget-header icontext">
                        <a href="#" class="icon icon-sm rounded-circle border"><i class="fa fa-user"></i></a>
                        <div class="text">
                            <span class="text-muted">Welcome!</span>
                            <div> 
                                <a href="#">Sign in</a> |  
                                <a href="#"> Register</a>
                            </div>
                        </div>
                    </div>
        
                </div> <!-- widgets-wrap.// -->
            </div> <!-- col.// -->
        </div> <!-- row.// -->
            </div> <!-- container.// -->
        </section> <!-- header-main .// -->
        
        
        
        <nav class="navbar navbar-main navbar-expand-lg navbar-light border-bottom">
          <div class="container">
        
            <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
              <span class="navbar-toggler-icon"></span>
            </button>
        
            <div class="collapse navbar-collapse" id="navbarNav">
              <ul class="navbar-nav">
                  <li class="nav-item dropdown">
                   <a class="nav-link" href="#">Home</a>
                </li>
                <li class="nav-item">
                  <a class="nav-link" href="#">About</a>
                </li>
                <li class="nav-item">
                  <a class="nav-link" href="#">Supermarket</a>
                </li>
                <li class="nav-item">
                  <a class="nav-link" href="#">Partnership</a>
                </li>
                <li class="nav-item">
                  <a class="nav-link" href="#">Baby &amp Toys</a>
                </li>
                <li class="nav-item">
                  <a class="nav-link" href="#">Fitness sport</a>
                </li>
                <li class="nav-item">
                  <a class="nav-link" href="#">Clothing</a>
                </li>
                <li class="nav-item">
                  <a class="nav-link" href="#">Furnitures</a>
                </li>
                <li class="nav-item dropdown">
                  <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
                    More
                  </a>
                  <ul class="dropdown-menu" aria-labelledby="navbarDropdown">
                    <li><a class="dropdown-item" href="#">Foods and Drink</a></li>
                    <li><a class="dropdown-item" href="#">Home interior</a></li>
                    <li><hr class="dropdown-divider"></li>
                    <li><a class="dropdown-item" href="#">Home interior 2</a></li>
                  </ul>
                </li>
              </ul>
            </div> <!-- collapse .// -->
          </div> <!-- container .// -->
        </nav>
        
        </header> <!-- section-header.// -->
        
        
        <!-- ========================= SECTION MAIN ========================= -->
        <section class="section-main bg padding-y">
        <div class="container">
        
        <div class="row">
            <aside class="col-md-3">
                <nav class="card">
                    <ul class="menu-category">
                        <li><a href="#">Best clothes</a></li>
                        <li><a href="#">Automobiles</a></li>
                        <li><a href="#">Home interior</a></li>
                        <li><a href="#">Electronics</a></li>
                        <li><a href="#">Technologies</a></li>
                        <li><a href="#">Digital goods</a></li>
                        <li class="has-submenu"><a href="#">More items</a>
                            <ul class="submenu">
                                <li><a href="#">Submenu name</a></li>
                                <li><a href="#">Great submenu</a></li>
                                <li><a href="#">Another menu</a></li>
                                <li><a href="#">Some others</a></li>
                            </ul>
                        </li>
                    </ul>
                </nav>
            </aside> <!-- col.// -->
            <div class="col-md-9">
                <article class="banner-wrap">
                    <img src="assets/images/2.jpg" class="w-100 rounded">
                </article>
            </div> <!-- col.// -->
        </div> <!-- row.// -->
        </div> <!-- container //  -->
        </section>
        <!-- ========================= SECTION MAIN END// ========================= -->
        
        <!-- ========================= SECTION  ========================= -->
        <section class="section-name padding-y-sm">
        <div class="container">
        
        <header class="section-heading">
            <a href="#" class="btn btn-outline-primary float-end">See all</a>
            <h3 class="section-title">Popular products</h3>
        </header><!-- sect-heading -->
        
            
        <div class="row">
            <div class="col-md-3">
                <div href="#" class="card card-product-grid">
                    <a href="#" class="img-wrap"> <img src="assets/images/items/1.jpg"> </a>
                    <figcaption class="info-wrap">
                        <a href="#" class="title">Just another product name</a>
                        <div class="price mt-1">$179.00</div> <!-- price-wrap.// -->
                    </figcaption>
                </div>
            </div> <!-- col.// -->
            <div class="col-md-3">
                <div href="#" class="card card-product-grid">
                    <a href="#" class="img-wrap"> <img src="assets/images/items/2.jpg"> </a>
                    <figcaption class="info-wrap">
                        <a href="#" class="title">Some item name here</a>
                        <div class="price mt-1">$280.00</div> <!-- price-wrap.// -->
                    </figcaption>
                </div>
            </div> <!-- col.// -->
            <div class="col-md-3">
                <div href="#" class="card card-product-grid">
                    <a href="#" class="img-wrap"> <img src="assets/images/items/3.jpg"> </a>
                    <figcaption class="info-wrap">
                        <a href="#" class="title">Great product name here</a>
                        <div class="price mt-1">$56.00</div> <!-- price-wrap.// -->
                    </figcaption>
                </div>
            </div> <!-- col.// -->
            <div class="col-md-3">
                <div href="#" class="card card-product-grid">
                    <a href="#" class="img-wrap"> <img src="assets/images/items/4.jpg"> </a>
                    <figcaption class="info-wrap">
                        <a href="#" class="title">Just another product name</a>
                        <div class="price mt-1">$179.00</div> <!-- price-wrap.// -->
                    </figcaption>
                </div>
            </div> <!-- col.// -->
            <div class="col-md-3">
                <div href="#" class="card card-product-grid">
                    <a href="#" class="img-wrap"> <img src="assets/images/items/5.jpg"> </a>
                    <figcaption class="info-wrap">
                        <a href="#" class="title">Just another product name</a>
                        <div class="price mt-1">$179.00</div> <!-- price-wrap.// -->
                    </figcaption>
                </div>
            </div> <!-- col.// -->
            <div class="col-md-3">
                <div href="#" class="card card-product-grid">
                    <a href="#" class="img-wrap"> <img src="assets/images/items/6.jpg"> </a>
                    <figcaption class="info-wrap">
                        <a href="#" class="title">Some item name here</a>
                        <div class="price mt-1">$280.00</div> <!-- price-wrap.// -->
                    </figcaption>
                </div>
            </div> <!-- col.// -->
            <div class="col-md-3">
                <div href="#" class="card card-product-grid">
                    <a href="#" class="img-wrap"> <img src="assets/images/items/7.jpg"> </a>
                    <figcaption class="info-wrap">
                        <a href="#" class="title">Great product name here</a>
                        <div class="price mt-1">$56.00</div> <!-- price-wrap.// -->
                    </figcaption>
                </div>
            </div> <!-- col.// -->
            <div class="col-md-3">
                <div href="#" class="card card-product-grid">
                    <a href="#" class="img-wrap"> <img src="assets/images/items/9.jpg"> </a>
                    <figcaption class="info-wrap">
                        <a href="#" class="title">Just another product name</a>
                        <div class="price mt-1">$179.00</div> <!-- price-wrap.// -->
                    </figcaption>
                </div>
            </div> <!-- col.// -->
        </div> <!-- row.// -->
        
        </div><!-- container // -->
        </section>
        <!-- ========================= SECTION  END// ========================= -->
        
        
        <!-- ========================= SECTION  ========================= -->
        <section class="section-name padding-y bg">
        <div class="container">
        
        <div class="row">
        <div class="col-md-6">
            <h3>Download app demo text</h3>
            <p>Get an amazing app  to make Your life easy</p>
        </div>
        <div class="col-md-6 text-md-end">
            <a href="#"><img src="assets/images/misc/appstore.png" height="40"></a>
            <a href="#"><img src="assets/images/misc/appstore.png" height="40"></a>
        </div>
        </div> <!-- row.// -->
        </div><!-- container // -->
        </section>
        <!-- ========================= SECTION  END// ======================= -->
        
        
        
        <!-- ========================= FOOTER ========================= -->
      <footer class="section-footer border-top bg">
        <div class="container">
          <section class="footer-top  padding-y">
            <div class="row">
              <aside class="col-md col-6">
                <h6 class="title">Brands</h6>
                <ul class="list-unstyled">
                  <li> <a href="#">Adidas</a></li>
                  <li> <a href="#">Puma</a></li>
                  <li> <a href="#">Reebok</a></li>
                  <li> <a href="#">Nike</a></li>
                </ul>
              </aside>
              <aside class="col-md col-6">
                <h6 class="title">Company</h6>
                <ul class="list-unstyled">
                  <li> <a href="#">About us</a></li>
                  <li> <a href="#">Career</a></li>
                  <li> <a href="#">Find a store</a></li>
                  <li> <a href="#">Rules and terms</a></li>
                  <li> <a href="#">Sitemap</a></li>
                </ul>
              </aside>
              <aside class="col-md col-6">
                <h6 class="title">Help</h6>
                <ul class="list-unstyled">
                  <li> <a href="#">Contact us</a></li>
                  <li> <a href="#">Money refund</a></li>
                  <li> <a href="#">Order status</a></li>
                  <li> <a href="#">Shipping info</a></li>
                  <li> <a href="#">Open dispute</a></li>
                </ul>
              </aside>
              <aside class="col-md col-6">
                <h6 class="title">Account</h6>
                <ul class="list-unstyled">
                  <li> <a href="#"> User Login </a></li>
                  <li> <a href="#"> User register </a></li>
                  <li> <a href="#"> Account Setting </a></li>
                  <li> <a href="#"> My Orders </a></li>
                </ul>
              </aside>
              <aside class="col-md">
                <h6 class="title">Social</h6>
                <ul class="list-unstyled">
                  <li><a href="#"> <i class="fab fa-facebook"></i> Facebook </a></li>
                  <li><a href="#"> <i class="fab fa-twitter"></i> Twitter </a></li>
                  <li><a href="#"> <i class="fab fa-instagram"></i> Instagram </a></li>
                  <li><a href="#"> <i class="fab fa-youtube"></i> Youtube </a></li>
                </ul>
              </aside>
            </div> <!-- row.// -->
          </section>	<!-- footer-top.// -->
      
          <section class="footer-bottom row">
            <div class="col-md-2">
              <p class="text-muted">   2021 Company name </p>
            </div>
            <div class="col-md-8 text-md-center">
              <span  class="px-2">info@com</span>
              <span  class="px-2">+000-000-0000</span>
              <span  class="px-2">Street name 123, ABC</span>
            </div>
            <div class="col-md-2 text-md-end text-muted">
              <i class="fab fa-lg fa-cc-visa"></i> 
              <i class="fab fa-lg fa-cc-paypal"></i> 
              <i class="fab fa-lg fa-cc-mastercard"></i>
            </div>
          </section>
        </div><!-- //container -->
      </footer>
      <!-- ========================= FOOTER END // ========================= -->

     

    Now we are done friends  also and If you have any kind of query or suggestion or any requirement then feel free to comment below. In my next post I will come with more Bootstrap 5 Free Templates.

    Note: Friends, I just tell the basic setup and things, you can change the code according to your requirements. For better understanding must watch video above.

    I will appreciate that if you will tell your views for this post. Nothing matters if your views will be good or bad.

    Jassa

    Thanks

  • Angular 12 Bootstrap 5 Free Responsive Template

    Angular 12 Bootstrap 5 Free Responsive Template

    Hello friends, welcome back to my blog. Today this blog post will tell you, Angular 12 Bootstrap 5 Free Responsive Template.

    In this post, guys we will cover below things:

    • Bootstrap 5 Angular 12 Free Template Creation.
    • Bootstrap 5 Carousel Slider Integration in Angular 12.
    • Angular 12 Bootstrap 5 Responsive Navbar.

    Angular Bootstrap Responsive Template

    Angular 12 Bootstrap 5 Free Responsive Template
    Angular 12 Bootstrap 5 Free Responsive Template

    Angular12 came and Bootstrap5 also and if you are new then you must check below two links:

    1. Angular12 Basic Tutorials
    2. Bootstrap 5

    Friends now I proceed onwards and here is the working code snippet and please use carefully this to avoid the mistakes:

    1. Firstly friends we need fresh angular 12 setup and for this we need to run below commands but if you already have angular 12 setup then you can avoid below commands. Secondly we should also have latest node version installed on our system:

    npm install -g @angular/cli 
    
    ng new angularboot5 //Create new Angular Project
    
    cd angularboot5 // Go inside the Angular Project Folder

    2. Now friends we need to run below commands into our project terminal to install bootstrap 5 modules into our angular application:

    npm install bootstrap@next

    3. Now friends we just need to add below code into angularboot5/src/app/app.component.html file to get final out on the web browser:

    <header>
      <!--Responsive Navbar -->
      <nav class="navbar navbar-expand-lg navbar-light bg-light">
          <div class="container">
              <a class="navbar-brand" target="_blank" href="#">
                  <img class="img-fluid" src="https://via.placeholder.com/180x45">
              </a>
              <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarText" aria-controls="navbarText" aria-expanded="false" aria-label="Toggle navigation">
                <span class="navbar-toggler-icon"></span>
              </button>
              <div class="collapse navbar-collapse" id="navbarText">
                <ul class="navbar-nav me-auto mb-2 mb-lg-0">
                      <li class="nav-item active">
                          <a class="nav-link p-3" href="#">Home <span class="sr-only">(current)</span></a>
                      </li>
                      <li class="nav-item">
                          <a class="nav-link p-3" href="#about-us">About us</a>
                      </li>
                      <li class="nav-item">
                          <a class="nav-link p-3" href="#features">Features</a>
                      </li>
                      <li class="nav-item">
                          <a class="nav-link p-3" href="#pricing">Pricing</a>
                      </li>
                      <li class="nav-item">
                          <a class="nav-link p-3" href="#testimonial">Testimonial</a>
                      </li>
                  </ul>
              </div>
          </div>
      </nav>
    </header>
    <main>
      <section>
          <!--Carousel Slider -->
          <div id="carouselExampleControls" class="carousel slide" data-bs-ride="carousel">
              <div class="carousel-inner">
                  <div class="carousel-item active">
                      <a target="_blank" href="#"><img src="https://via.placeholder.com/1468x500" class="d-block w-100" alt="..."></a>
                  </div>
                  <div class="carousel-item">
                      <a target="_blank" href="#"><img src="https://via.placeholder.com/1468x500" class="d-block w-100" alt="..."></a>
                  </div>
                  <div class="carousel-item">
                      <a target="_blank" href="#"><img src="https://via.placeholder.com/1468x500" class="d-block w-100" alt="..."></a>
                  </div>
              </div>
              <a class="carousel-control-prev" href="#carouselExampleControls" role="button" data-bs-target="#carouselExampleControls" data-bs-slide="prev">
                  <span class="carousel-control-prev-icon" aria-hidden="true"></span>
                  <span class="sr-only">Previous</span>
              </a>
              <a class="carousel-control-next" href="#carouselExampleControls" role="button" data-bs-target="#carouselExampleControls" data-bs-slide="next">
                  <span class="carousel-control-next-icon" aria-hidden="true"></span>
                  <span class="sr-only">Next</span>
              </a>
          </div>
      </section>
      <section id="about-us" class="py-5">
          <div class="container">
              <div class="text-center py-4">
                  <h1>Simple Landing Page</h1>
              </div>
              <div class="row">
                  <div class="col-md-3">
                      <a target="_blank" href="#">
                          <img src="https://via.placeholder.com/250x250" class="d-block img-fluid" alt="...">
                      </a>
                  </div>
                  <div class="col-md-9">
                      <p class="lead text-muted">Lorem ipsum, or lipsum as it is sometimes known, is dummy text used in laying out print, graphic or web designs. The passage is attributed to an unknown typesetter in the 15th century who is thought to have scrambled parts of Cicero's De Finibus Bonorum et Malorum for use in a type specimen book. It usually begins. Lorem ipsum, or lipsum as it is sometimes known, is dummy text used in laying out print, graphic or web designs. The passage is attributed to an unknown typesetter in the 15th century.</p>
                      <p>
                          <a href="#" class="btn btn-primary my-2 me-2">More Details</a>
                          <a href="#" class="btn btn-secondary my-2">Contact Us</a>
                      </p>
                  </div>
              </div>
          </div>
      </section>
    
      <section id="features" class="py-5 bg-light">
          <div class="container">
              <div class="text-center py-4">
                  <h1>Features</h1>
              </div>
              <div class="row">
                  <div class="col-md-4 col-sm-4 mb-2">
                      <div class="box-part text-center">
                          <i class="text-primary fas fa-heart fa-3x mb-3" aria-hidden="true"></i>
                          <div class="title">
                              <h4>Premium Design</h4>
                          </div>
                          <div class="text mb-3">
                              <span>Lorem ipsum dolor sit amet, id quo eruditi eloquentiam. Assum decore te sed. Elitr scripta ocurreret qui ad.</span>
                          </div>
                          <a class="btn btn-outline-primary" href="#">Learn More</a>
                      </div>
                  </div>
                  <div class="col-md-4 col-sm-4 mb-2">
                      <div class="box-part text-center">
                          <i class="text-success fas fa-laptop fa-3x mb-3" aria-hidden="true"></i>
                          <div class="title">
                              <h4>Responsive Design</h4>
                          </div>
                          <div class="text mb-3">
                              <span>Lorem ipsum dolor sit amet, id quo eruditi eloquentiam. Assum decore te sed. Elitr scripta ocurreret qui ad.</span>
                          </div>
                          <a class="btn btn-outline-success" href="#">Learn More</a>
                      </div>
                  </div>
                  <div class="col-md-4 col-sm-4 mb-2">
                      <div class="box-part text-center">
                          <i class="text-danger fas fa-box-open fa-3x mb-3" aria-hidden="true"></i>
                          <div class="title">
                              <h4>Easy to Manage</h4>
                          </div>
                          <div class="text mb-3">
                              <span>Lorem ipsum dolor sit amet, id quo eruditi eloquentiam. Assum decore te sed. Elitr scripta ocurreret qui ad.</span>
                          </div>
                          <a class="btn btn-outline-danger" href="#">Learn More</a>
                      </div>
                  </div>
              </div>
          </div>
      </section>
    
      <section id="pricing" class="py-5">
          <div class="container">
            <div class="row text-center">
              <div class="py-4">
                  <h1>Pricing</h1>
              </div>
              
                  <div class="col-sm-4 mb-2">
                    <div class="card shadow-sm">
                      <div class="card-header bg-light">
                          <h4 class="my-0 font-weight-normal">Free</h4>
                      </div>
                      <div class="card-body bg-light">
                          <h1 class="card-title pricing-card-title">$0 <small class="text-muted">/ mo</small></h1>
                          <ul class="list-unstyled mt-3 mb-4">
                              <li>10 users included</li>
                              <li>2 GB of storage</li>
                              <li>Email support</li>
                              <li>Help center access</li>
                          </ul>
                          <button type="button" class="btn btn-block btn-outline-primary">Get started</button>
                      </div>
                    </div>
                  </div>
                  <div class="col-sm-4 mb-2">
                    <div class="card shadow-sm">
                      <div class="card-header bg-info text-light">
                          <h4 class="my-0 font-weight-normal">Pro</h4>
                      </div>
                      <div class="card-body bg-info text-light">
                          <h1 class="card-title pricing-card-title">$15 <small>/ mo</small></h1>
                          <ul class="list-unstyled mt-3 mb-4">
                              <li>20 users included</li>
                              <li>10 GB of storage</li>
                              <li>Priority email support</li>
                              <li>Help center access</li>
                          </ul>
                          <button type="button" class="btn btn-block btn-light">Get started</button>
                      </div>
                    </div>
                  </div>
                  <div class="col-sm-4 mb-2">
                    <div class="card shadow-sm">
                      <div class="card-header bg-success text-light">
                          <h4 class="my-0 font-weight-normal">Enterprise</h4>
                      </div>
                      <div class="card-body bg-success text-light">
                          <h1 class="card-title pricing-card-title">$29 <small>/ mo</small></h1>
                          <ul class="list-unstyled mt-3 mb-4">
                              <li>30 users included</li>
                              <li>15 GB of storage</li>
                              <li>Phone and email support</li>
                              <li>Help center access</li>
                          </ul>
                          <button type="button" class="btn btn-block btn-light">Get started</button>
                      </div>
                    </div>
                  </div>
              
          </div>
        </div>
      </section>
    
      <section id="testimonial" class="py-5 bg-light">
          <div class="container">
              <div class="text-center py-4">
                  <h1>Testimonials</h1>
              </div>
             
                    <div class="row">
                     
                        
                              <div class="col-md-4">
                                  <div class="card mb-4 shadow-sm">
                                      <a href="#">
                                          <img class="img-fluid" src="https://via.placeholder.com/416x225" alt="">
                                      </a>
                                      <div class="card-body">
                                          <div class="stars d-inline">
                                              <span class="fas fa-star text-warning"></span>
                                              <span class="fas fa-star text-warning"></span>
                                              <span class="fas fa-star text-warning"></span>
                                              <span class="fas fa-star text-warning"></span>
                                              <span class="fas fa-star"></span>
                                          </div>
                                          <p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
                                          <div class="d-flex justify-content-between align-items-center">
                                              <small class="text-muted">By Jassa</small>
                                          </div>
                                      </div>
                                  </div>
                              </div>
                             
                              <div class="col-md-4">
                                  <div class="card mb-4 shadow-sm">
                                      <a href="#">
                                          <img class="img-fluid" src="https://via.placeholder.com/416x225" alt="">
                                      </a>
                                      <div class="card-body">
                                          <div class="stars d-inline">
                                              <span class="fas fa-star text-warning"></span>
                                              <span class="fas fa-star text-warning"></span>
                                              <span class="fas fa-star text-warning"></span>
                                              <span class="fas fa-star text-warning"></span>
                                              <span class="fas fa-star"></span>
                                          </div>
                                          <p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
                                          <div class="d-flex justify-content-between align-items-center">
                                              <small class="text-muted">By Jassa</small>
                                          </div>
                                      </div>
                                  </div>
                              </div>
                           
                              <div class="col-md-4">
                                  <div class="card mb-4 shadow-sm">
                                      <a href="#">
                                          <img class="img-fluid" src="https://via.placeholder.com/416x225" alt="">
                                      </a>
                                      <div class="card-body">
                                          <div class="stars d-inline">
                                              <span class="fas fa-star text-warning"></span>
                                              <span class="fas fa-star text-warning"></span>
                                              <span class="fas fa-star text-warning"></span>
                                              <span class="fas fa-star text-warning"></span>
                                              <span class="fas fa-star"></span>
                                          </div>
                                          <p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
                                          <div class="d-flex justify-content-between align-items-center">
                                              <small class="text-muted">By Jassa</small>
                                          </div>
                                      </div>
                                  </div>
                              </div>
              </div>
          </div>
      </section>
    
    </main>
    <footer class="pt-4 pt-md-5 border-top">
      <div class="container">
          <div class="row">
              <div class="col-12 col-md">
                  <a href="#">
                      <img class="img-fluid" src="https://via.placeholder.com/250x65">
                  </a>
              </div>
              <div class="col-6 col-md">
                  <h5>Features</h5>
                  <ul class="list-unstyled text-small">
                      <li><a class="text-muted" href="#">Cool stuff</a></li>
                      <li><a class="text-muted" href="#">Random feature</a></li>
                      <li><a class="text-muted" href="#">Team feature</a></li>
                      <li><a class="text-muted" href="#">Stuff for developers</a></li>
                      <li><a class="text-muted" href="#">Another one</a></li>
                      <li><a class="text-muted" href="#">Last time</a></li>
                  </ul>
              </div>
              <div class="col-6 col-md">
                  <h5>Resources</h5>
                  <ul class="list-unstyled text-small">
                      <li><a class="text-muted" href="#">Resource</a></li>
                      <li><a class="text-muted" href="#">Resource name</a></li>
                      <li><a class="text-muted" href="#">Another resource</a></li>
                      <li><a class="text-muted" href="#">Final resource</a></li>
                  </ul>
              </div>
              <div class="col-6 col-md">
                  <h5>About</h5>
                  <ul class="list-unstyled text-small">
                      <li><a class="text-muted" href="#">Team</a></li>
                      <li><a class="text-muted" href="#">Locations</a></li>
                      <li><a class="text-muted" href="#">Privacy</a></li>
                      <li><a class="text-muted" href="#">Terms</a></li>
                  </ul>
              </div>
          </div>
      </div>
      <div class="text-center py-4 bg-light mt-4">Copyright 2021 | All right reserved</div>
    </footer>

    4. Now friends we just need to add below code into angularboot5/angular.json file:

    "styles": [
                  ...
                  "node_modules/bootstrap/dist/css/bootstrap.min.css"
              ],
    "scripts": [
                  ...
                   "node_modules/bootstrap/dist/js/bootstrap.min.js"
               ]

    5. Now friends we just need to add below code into angularboot5/src/app/app.component.css file to add custom styles:

    a{
        text-decoration: none!important;
      }

    6. Now friends we just need to add below code into angularboot5/src/index.html file to add fontawesome icons:

    <!DOCTYPE html>
    <html lang="">
      <head>
       ...
        <link href="https://use.fontawesome.com/releases/v5.7.0/css/all.css" rel="stylesheet">
     
      </head>
    ...
    

    Friends in the end must run ng serve command into your terminal to run the angular 12 project (localhost:4200).

    Guys click here to check the Angular 12 Bootstrap 5 Free Templates.

    Now we are done friends. If you have any kind of query, suggestion and new requirement then feel free to comment below.

    Note: Friends, In this post, I just tell the basic setup and things, you can change the code according to your requirements.

    I will appreciate that if you will tell your views for this post. Nothing matters if your views will be good or bad because with your views, I will make my next posts more good and helpful.

    Jassa

    Thanks

  • Angular 12 Chartjs Working Demo

    Angular 12 Chartjs Working Demo

    Hello to all, welcome to therichpost.com. In this post, I will tell you, Angular 12 Chartjs Working Demo.

    Angular 12 Chartjs
    Angular 12 Chartjs Working Demo
    Angular 12 Chartjs Working Demo

    Angular12 came and if you are new then you must check below link:

    1. Angular 12 Tutorials

    Here is the code snippet and please use carefully:

    1. Very first guys, here are common basics steps to add angular 12 application on your machine and also we must have latest nodejs version(14.17.0) installed for angular 12:

    $ npm install -g @angular/cli
    
    $ ng new angularcharts // Set Angular 11 Application on your pc
    
    cd angularcharts // Go inside project folder

    2. Now run below commands to set chartjs modules into our angular 12 application:

    npm install angular2-chartjs

    3. Now we will add below code into our angularcharts/src/app/app.module.ts file:

    ...
    import { ChartModule } from 'angular2-chartjs';
    @NgModule({
      ..
      imports: [
       ...
        ChartModule
      ],

    4. Now we will add below code into our angularcharts/src/app/app.component.ts file:

    ...
    
    export class AppComponent {
      ...
      
      //line chart
      type = 'line';
      data = {
        labels: ["January", "February", "March", "April", "May", "June", "July"],
        datasets: [{
          label: "My First dataset",
          data: [65, 59, 45, 81, 56, 55, 40],
          backgroundColor: ["#f38b4a"],
        },{
            label: "My Second dataset",
            data: [80, 59, 75, 81, 85, 55, 40],
            backgroundColor: ["#6970d5"],
          }]
      };
      options = {
        responsive: true,
        maintainAspectRatio: false
      };
    
    }
    

    5. Finally we will add below code into our angularcharts/src/app/app.component.html file:

    <chart [type]="type" [data]="data" [options]="options"></chart>
    

    Now we are done friends and please run ng serve command to check the output in browser(locahost:4200) and if you have any kind of query then please do comment below.

    Note: Friends, I just tell the basic setup and things, you can change the code according to your requirements. For better understanding must watch video above.

    I will appreciate that if you will tell your views for this post. Nothing matters if your views will be good or bad.

    Jassa

    Thanks

  • Angular 12 Crud Tutorial with Services Part 1 – Add User & Get Users

    Angular 12 Crud Tutorial with Services Part 1 – Add User & Get Users

    Hello to all welcome back on my blog therichpost.com. Today in this blog post, I am going to tell you Angular 12 Crud. Angular 12 Crud Tutorial with Services Part 1 – Add User & Get Users.

    In this post, we will cover below things:

    1. Angular12 Crud with PHP MySQL backend.
    2. Angular 12 Crud with services.
    3. Angular 12 Reactive Forms.
    4. Bootstrap 5 in Angular 12.
    Angular 12 Crud Working Video
    Angular 12 Crud Tutorial with Services Part 1 - Add User & Get Users
    Angular 12 Crud Tutorial with Services Part 1 – Add User & Get Users
    Angular12 Reactive Forms
    Angular 12 Crud Tutorial with Services Get Users
    Angular 12 Crud Tutorial with Services Get Users

    Guys Angular 12 and if you are new in Angular 12 then please check below link:

    1. Angular 12 Tutorials

    Guys here is working code snippet and please follow carefully to avoid the mistakes:

    1. Firstly friends we need fresh angular 12 setup and for this we need to run below commands but if you already have angular 12 setup then you can avoid below commands. Secondly we should also have latest node version(14.17.0) installed on our system:

    npm install -g @angular/cli 
    
    ng new angularcrud //Create new Angular Project
    
    cd angularcrud // Go inside the Angular Project Folder

    2. Now friends, here we need to run below commands into our project terminal to install bootstrap 5 module for styling,  into our angular application:

    npm install bootstrap

    3. Now friends, here we need to run below commands into our project terminal to create service file and user related components:

    ng g service crud //create service file
    
    ng g c users //create user component
    
    ng g c adduser //create add user component

    4. Now friends, now we need to add below code into our angularcrud/angular.json file to add bootstrap style:

    ...
     "styles": [
                  "src/styles.css",
                  "node_modules/bootstrap/dist/css/bootstrap.min.css",
                  
                ],

    5. Now friends, now we need to add below code into our angularcrud/src/app/app.module.ts file to import reactive form module and HTTPCLIENT module for api calling:

    ...
    
    import { ReactiveFormsModule } from '@angular/forms';
    import { HttpClientModule } from '@angular/common/http';
    
    @NgModule({
      ...
      imports: [
       ...
        HttpClientModule,
        ReactiveFormsModule
      ]...
    

    6. Now friends, now we need to add below code into our angularcrud/src/app/app-routing.module.ts file to make routes:

    ...
    import { UsersComponent } from './users/users.component';
    import { AdduserComponent } from './adduser/adduser.component';
    const routes: Routes = [
      { path: '', component: UsersComponent },
      { path: 'users', component: UsersComponent },
      { path: 'adduser', component: AdduserComponent },
    ];
    ...
    

    7. Now friends, now we need to add below code into our angularcrud/src/app/crud.service.ts file to create API services:

    import { Injectable } from '@angular/core';
    import { HttpClient } from '@angular/common/http';
    @Injectable({
      providedIn: 'root'
    })
    export class CrudService {
      userData:any;
      constructor(private http:HttpClient) { }
    
      //get all users  details
      public getusers()
          {
            
              return this.http.get('http://localhost/users.php');
          }
    
      //add new user    
      public adduser(userData)
      {
        return this.http.post('http://localhost/users.php/'
      , userData).subscribe((res: Response) => {
        this.getusers();
      });
      }
        
    }

    8. Now guys, now we need to add below code into our angularcrud/src/app/app.component.html file to set the angular frontend and call others components:

    <nav class="navbar navbar-expand-lg navbar-light bg-light">
      <div class="container-fluid">
        <a class="navbar-brand" [routerLink]="['']">Therichpost</a>
        <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
          <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse" id="navbarNav">
          <ul class="navbar-nav">
            <li class="nav-item">
              <a class="nav-link active" [routerLink]="['']" >Home</a>
            </li>
            <li class="nav-item">
              <a class="nav-link" [routerLink]="['/users']" >Users</a>
            </li>
            <li class="nav-item">
              <a class="nav-link" [routerLink]="['/adduser']" >Add User</a>
            </li>
           
          </ul>
        </div>
      </div>
    </nav>
    <router-outlet></router-outlet>

    9. Now guys, now we need to add below code into our angularcrud/src/app/adduser/adduser.component.ts file to create add user functionality and reactive form validations:

    import { Component, OnInit } from '@angular/core';
    import { FormBuilder, FormGroup, Validators } from '@angular/forms';
    import { CrudService } from '../crud.service'; 
    import { Router } from '@angular/router';
    @Component({
      selector: 'app-adduser',
      templateUrl: './adduser.component.html',
      styleUrls: ['./adduser.component.css']
    })
    export class AdduserComponent implements OnInit {
    
    registerForm: FormGroup;
    submitted = false;
    constructor( private crudservice: CrudService, private formBuilder: FormBuilder, private router: Router){}
    //Add user form actions
    get f() { return this.registerForm.controls; }
    onSubmit() {
      
      this.submitted = true;
      // stop here if form is invalid
      if (this.registerForm.invalid) {
          return;
      }
      //True if all the fields are filled
      if(this.submitted)
      {
        
        // Initialize Params Object
         var myFormData = new FormData();
      
       // Begin assigning parameters
      
          myFormData.append('myUsername', this.registerForm.value.firstname);
          myFormData.append('myEmail', this.registerForm.value.email);
      
          this.crudservice.adduser(myFormData); //caaling add user service
          this.router.navigate([`/users`]); //after form submit page will redirect to users page
      }
     
    }
      ngOnInit() {
        //Add User form validations
        this.registerForm = this.formBuilder.group({
        email: ['', [Validators.required, Validators.email]],
       
        firstname: ['', [Validators.required]]
        });
      }
    
    }
    

    10. Now guys, now we need to add below code into our angularcrud/src/app/adduser/adduser.component.html file to create add user form:

    <div class="container p-5">
        <h1 class="text-left mb-5">Add User</h1>
      <form [formGroup]="registerForm" (ngSubmit)="onSubmit()">
        <div class="row">
           <div class="col-sm-6">
              <div class="form-group">
                    <label>Username</label>
                    <input type="text" formControlName="firstname" class="form-control" [ngClass]="{ 'is-invalid': submitted && f.firstname.errors }" />
                    <div *ngIf="submitted && f.firstname.errors" class="invalid-feedback">
                          <div *ngIf="f.firstname.errors.required">Name is required</div>
                    </div>
                 </div>
           </div> 
           <div class="col-sm-6">
              <div class="form-group">
                 <label>Email</label>
                 <input type="text" formControlName="email" class="form-control" [ngClass]="{ 'is-invalid': submitted && f.email.errors }" />
                 <div *ngIf="submitted && f.email.errors" class="invalid-feedback">
                    <div *ngIf="f.email.errors.required">Email is required</div>
                    <div *ngIf="f.email.errors.email">Email must be a valid email address</div>
                 </div>
              </div>
           </div>
           
           
       </div>
       <button type="submit" class="btn btn-primary">Submit</button>
      </form>
      </div>

    11. Now guys, now we need to add below code into our angularcrud/src/app/users/users.component.ts file to create get all users details functionality:

    ...
    import { CrudService } from '../crud.service'; 
    @Component({
      selector: 'app-users',
      templateUrl: './users.component.html',
      styleUrls: ['./users.component.css']
    })
    export class UsersComponent implements OnInit {
      data = [];
      constructor( private crudservice: CrudService){
        //Get all usera details  
        this.crudservice.getusers().subscribe((res: any[])=>{
              
          this.data = res;
        });
      }
    
      ngOnInit(): void {
      }
    
    }
    

    12. Now guys, now we need to add below code into our angularcrud/src/app/users/users.component.html file to create show users details table:

    <div class="container p-5">
        <h1>Users</h1>
        <table class="table table-hover table-bordered">
            <thead>
              <tr>
                <th>ID</th>
                <th>Email</th>
                <th>Username</th>
              </tr>
            </thead>
            <tbody>
           
               
                  <tr *ngFor="let group of data">
                    <td>{{group.id}}</td>
                    <td>{{group.email}}</td>
                    <td>{{group.username}}</td>
                  </tr>
               
             
             
              
            </tbody>
          </table>
    
         
    </div>

    13. Now guys, now we need to create file users.php inside our xampp/htdocs folder and add below code inside users.php file

    Please create users database inside phpmysql admin and create userdetails tabel and create id, email and username fields

    <?php header('Access-Control-Allow-Origin: *');
    header('Access-Control-Allow-Credentials: true');
    header('Access-Control-Allow-Methods:POST,GET,PUT,DELETE');
    header('Access-Control-Allow-Headers: content-type or other');
    header('Content-Type: application/json');
    
    //Please create users database inside phpmysql admin and create userdetails tabel and create id, email and username fields
    
    $servername = "localhost";
    $username   = "root";
    $password   = "";
    $dbname     = "users";
    // Create connection
    $conn = new mysqli($servername, $username, $password, $dbname);
    // Check connection
    if ($conn->connect_error) {
        die("Connection failed: " . $conn->connect_error);
    } 
    
    //Add user
    if(isset($_POST['myEmail']))
    {
        $sql = "INSERT INTO userdetails (email, username)
            VALUES ('".$_POST['myEmail']."', '".$_POST['myUsername']."')";
        if (mysqli_query($conn,$sql)) {
        $data = array("data" => "You Data added successfully");
            echo json_encode($data);
        } else {
            $data = array("data" => "Error: " . $sql . "<br>" . $conn->error);
            echo json_encode($data);
            
        }
    }
    else
    {
        //get all users details
        $trp = mysqli_query($conn, "SELECT * from userdetails ORDER BY id DESC");
        $rows = array();
        while($r = mysqli_fetch_assoc($trp)) {
            $rows[] = $r;
        }
    
       
    
        print json_encode($rows);
    }
    
    die();
    

    Now in the end please run ng serve command to check the out on browser(localhost:4200) and also please start your xampp.

    After this post, I will do edit user and delete user also.

    Guys if you will still have any kind of query, suggestions or requirement then please feel free to comment below.

    I will appreciate that if you will tell your views for this post. Nothing matters if your views will be good or bad because with your views, I will make my next posts more good and helpful.

    Jassa

    Thanks

  • Laravel 8 Bootstrap 5 Admin Dashboard Template Free

    Laravel 8 Bootstrap 5 Admin Dashboard Template Free

    Hello friends, welcome back on blog. Today in this blog post, I am going to tell you, Laravel 8 Bootstrap 5 Admin Dashboard Template Free.

    Laravel 8 Admin Template

    Laravel 8 Bootstrap 5 Admin Dashboard Template Free
    Laravel 8 Bootstrap 5 Admin Dashboard Template Free

    Guys if you are new in Laravel 8 and Bootstrap 5 the please check below links for Laravel basics information:

    1. Laravel Basics Tutorial for beginners
    2. Bootstrap 5

    Here is the code snippet and please use carefully:

    1. Friends here is the code below and you can add into your resources/views/ welcome.blade.php file:

    Guys for demo purpose, I have used this code into my welcome blade:

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <title>Richpost Admin Template</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    
        <!-- Custom styles for this template -->
       <!-- Custom CSS -->
       <link href="assets/css/chartist.min.css" rel="stylesheet">
       <link rel="stylesheet" href="assets/css/chartist-plugin-tooltip.css">
       <!-- Custom CSS -->
       <link href="assets/css/style.min.css" rel="stylesheet">
        <!-- All Jquery -->
        <!-- ============================================================== -->
       
        <!-- Bootstrap tether Core JavaScript -->
        <script src="assets/js/bootstrap.bundle.min.js"></script>
        
        <!--This page JavaScript -->
        <!--chartis chart-->
        <script src="assets/js/jquery.min.js"></script>
        <script src="assets/js/chartist.min.js"></script>
        <script src="assets/js/chartist-plugin-tooltip.min.js"></script>
        <script src="assets/js/jquery.sparkline.min.js"></script>
         <!--Custom JavaScript -->
        <script src="assets/js/custom.js"></script>
    
    </head>
    <body>
    
    <!-- ============================================================== -->
        <!-- Preloader -->
        <!-- ============================================================== -->
        <div class="preloader">
          <div class="lds-ripple">
              <div class="lds-pos"></div>
              <div class="lds-pos"></div>
          </div>
      </div>
      <!-- ============================================================== -->
      <!-- Main wrapper -->
      <!-- ============================================================== -->
      <div id="main-wrapper" data-layout="vertical" data-navbarbg="skin5" data-sidebartype="full"
          data-sidebar-position="absolute" data-header-position="absolute" data-boxed-layout="full">
          <!-- ============================================================== -->
          <!-- Topbar header -->
          <!-- ============================================================== -->
          <header class="topbar" data-navbarbg="skin5">
              <nav class="navbar top-navbar navbar-expand-md navbar-dark">
                  <div class="navbar-header" data-logobg="skin6">
                      <!-- ============================================================== -->
                      <!-- Logo -->
                      <!-- ============================================================== -->
                      <a class="navbar-brand" href="#">
                          <!-- Logo icon -->
                          <b class="logo-icon">
                              <!-- Dark Logo icon -->
                              TheRichPost
                          </b>
                          <!--End Logo icon -->
                          <!-- Logo text -->
                          <span class="logo-text">
                              <!-- dark Logo text -->
                             Admin
                          </span>
                      </a>
                      <!-- ============================================================== -->
                      <!-- End Logo -->
                      <!-- ============================================================== -->
                      <!-- ============================================================== -->
                      <!-- toggle and nav items -->
                      <!-- ============================================================== -->
                      <a class="nav-toggler waves-effect waves-light text-dark d-block d-md-none"
                          href="javascript:void(0)"><i class="ti-menu ti-close"></i></a>
                  </div>
                  <!-- ============================================================== -->
                  <!-- End Logo -->
                  <!-- ============================================================== -->
                  <div class="navbar-collapse collapse" id="navbarSupportedContent" data-navbarbg="skin5">
                     
                      <!-- ============================================================== -->
                      <!-- Right side toggle and nav items -->
                      <!-- ============================================================== -->
                      <ul class="navbar-nav ms-auto d-flex align-items-center">
    
                          <!-- ============================================================== -->
                          <!-- Search -->
                          <!-- ============================================================== -->
                          <li class=" in">
                              <form role="search" class="app-search d-none d-md-block me-3">
                                  <input type="text" placeholder="Search..." class="form-control mt-0">
                                  <a href="" class="active">
                                      <i class="fa fa-search"></i>
                                  </a>
                              </form>
                          </li>
                          <!-- ============================================================== -->
                          <!-- User profile and search -->
                          <!-- ============================================================== -->
                          <li>
                              <a class="profile-pic" href="#">
                                  <img src="https://therichpost.com/wp-content/uploads/2021/03/avatar2.png" alt="user-img" width="36"
                                      class="img-circle"><span class="text-white font-medium">Steave</span></a>
                          </li>
                          <!-- ============================================================== -->
                          <!-- User profile and search -->
                          <!-- ============================================================== -->
                      </ul>
                  </div>
              </nav>
          </header>
          <!-- ============================================================== -->
          <!-- End Topbar header -->
          <!-- ============================================================== -->
          <!-- ============================================================== -->
          <!-- Left Sidebar -->
          <!-- ============================================================== -->
          <aside class="left-sidebar" data-sidebarbg="skin6">
              <!-- Sidebar scroll-->
              <div class="scroll-sidebar">
                  <!-- Sidebar navigation-->
                  <nav class="sidebar-nav">
                      <ul id="sidebarnav">
                          <!-- User Profile-->
                          <li class="sidebar-item pt-2">
                              <a class="sidebar-link waves-effect waves-dark sidebar-link" href="#"
                                  aria-expanded="false">
                                  <i class="far fa-clock" aria-hidden="true"></i>
                                  <span class="hide-menu">Dashboard</span>
                              </a>
                          </li>
                          <li class="sidebar-item">
                              <a class="sidebar-link waves-effect waves-dark sidebar-link" href="#"
                                  aria-expanded="false">
                                  <i class="fa fa-user" aria-hidden="true"></i>
                                  <span class="hide-menu">Profile</span>
                              </a>
                          </li>
                          <li class="sidebar-item">
                              <a class="sidebar-link waves-effect waves-dark sidebar-link" href="#"
                                  aria-expanded="false">
                                  <i class="fa fa-table" aria-hidden="true"></i>
                                  <span class="hide-menu">Basic Table</span>
                              </a>
                          </li>
                         
                      </ul>
    
                  </nav>
                  <!-- End Sidebar navigation -->
              </div>
              <!-- End Sidebar scroll-->
          </aside>
          <!-- ============================================================== -->
          <!-- End Left Sidebar -->
          <!-- ============================================================== -->
          <!-- ============================================================== -->
          <!-- Page wrapper  -->
          <!-- ============================================================== -->
          <div class="page-wrapper">
              <!-- ============================================================== -->
              <!-- Bread crumb -->
              <!-- ============================================================== -->
              <div class="page-breadcrumb bg-white">
                  <div class="row align-items-center">
                      <div class="col-lg-3 col-md-4 col-sm-4 col-xs-12">
                          <h4 class="page-title">Dashboard</h4>
                      </div>
                      <div class="col-lg-9 col-sm-8 col-md-8 col-xs-12">
                          <div class="d-md-flex">
                              <ol class="breadcrumb ms-auto">
                                  <li><a href="#" class="fw-normal">Bootstrap 5</a></li>
                              </ol>
                             
                          </div>
                      </div>
                  </div>
                  <!-- /.col-lg-12 -->
              </div>
              <!-- ============================================================== -->
              <!-- End Bread -->
              <!-- ============================================================== -->
              <!-- ============================================================== -->
              <!-- Container fluid  -->
              <!-- ============================================================== -->
              <div class="container-fluid">
                  <!-- ============================================================== -->
                  <!-- Three charts -->
                  <!-- ============================================================== -->
                  <div class="row justify-content-center">
                      <div class="col-lg-4 col-md-12">
                          <div class="white-box analytics-info">
                              <h3 class="box-title">Total Visit</h3>
                              <ul class="list-inline two-part d-flex align-items-center mb-0">
                                  <li>
                                      <div id="sparklinedash"><canvas width="67" height="30"
                                              style="display: inline-block; width: 67px; height: 30px; vertical-align: top;"></canvas>
                                      </div>
                                  </li>
                                  <li class="ms-auto"><span class="counter text-success">659</span></li>
                              </ul>
                          </div>
                      </div>
                      <div class="col-lg-4 col-md-12">
                          <div class="white-box analytics-info">
                              <h3 class="box-title">Total Page Views</h3>
                              <ul class="list-inline two-part d-flex align-items-center mb-0">
                                  <li>
                                      <div id="sparklinedash2"><canvas width="67" height="30"
                                              style="display: inline-block; width: 67px; height: 30px; vertical-align: top;"></canvas>
                                      </div>
                                  </li>
                                  <li class="ms-auto"><span class="counter text-purple">869</span></li>
                              </ul>
                          </div>
                      </div>
                      <div class="col-lg-4 col-md-12">
                          <div class="white-box analytics-info">
                              <h3 class="box-title">Unique Visitor</h3>
                              <ul class="list-inline two-part d-flex align-items-center mb-0">
                                  <li>
                                      <div id="sparklinedash3"><canvas width="67" height="30"
                                              style="display: inline-block; width: 67px; height: 30px; vertical-align: top;"></canvas>
                                      </div>
                                  </li>
                                  <li class="ms-auto"><span class="counter text-info">911</span>
                                  </li>
                              </ul>
                          </div>
                      </div>
                  </div>
                  <!-- ============================================================== -->
                  <!-- PRODUCTS YEARLY SALES -->
                  <!-- ============================================================== -->
                  <div class="row">
                      <div class="col-md-12 col-lg-12 col-sm-12 col-xs-12">
                          <div class="white-box">
                              <h3 class="box-title">Products Yearly Sales</h3>
                              <div class="d-md-flex">
                                  <ul class="list-inline d-flex ms-auto">
                                      <li class="ps-3">
                                          <h5><i class="fa fa-circle me-1 text-info"></i>Mac</h5>
                                      </li>
                                      <li class="ps-3">
                                          <h5><i class="fa fa-circle me-1 text-inverse"></i>Windows</h5>
                                      </li>
                                  </ul>
                              </div>
                              <div id="ct-visits" style="height: 405px;">
                                  <div class="chartist-tooltip" style="top: -17px; left: -12px;"><span
                                          class="chartist-tooltip-value">6</span>
                                  </div>
                              </div>
                          </div>
                      </div>
                  </div>
                  <!-- ============================================================== -->
                  <!-- RECENT SALES -->
                  <!-- ============================================================== -->
                  <div class="row">
                      <div class="col-md-12 col-lg-12 col-sm-12">
                          <div class="white-box">
                              <div class="d-md-flex mb-3">
                                  <h3 class="box-title mb-0">Recent sales</h3>
                                  <div class="col-md-3 col-sm-4 col-xs-6 ms-auto">
                                      <select class="form-select shadow-none row border-top">
                                          <option>March 2021</option>
                                          <option>April 2021</option>
                                          <option>May 2021</option>
                                          <option>June 2021</option>
                                          <option>July 2021</option>
                                      </select>
                                  </div>
                              </div>
                              <div class="table-responsive">
                                  <table class="table no-wrap">
                                      <thead>
                                          <tr>
                                              <th class="border-top-0">#</th>
                                              <th class="border-top-0">Name</th>
                                              <th class="border-top-0">Status</th>
                                              <th class="border-top-0">Date</th>
                                              <th class="border-top-0">Price</th>
                                          </tr>
                                      </thead>
                                      <tbody>
                                          <tr>
                                              <td>1</td>
                                              <td class="txt-oflo">Elite admin</td>
                                              <td>SALE</td>
                                              <td class="txt-oflo">April 18, 2021</td>
                                              <td><span class="text-success">$24</span></td>
                                          </tr>
                                          <tr>
                                              <td>2</td>
                                              <td class="txt-oflo">Real Homes WP Theme</td>
                                              <td>EXTENDED</td>
                                              <td class="txt-oflo">April 19, 2021</td>
                                              <td><span class="text-info">$1250</span></td>
                                          </tr>
                                          <tr>
                                              <td>3</td>
                                              <td class="txt-oflo">Rich Admin</td>
                                              <td>EXTENDED</td>
                                              <td class="txt-oflo">April 19, 2021</td>
                                              <td><span class="text-info">$1250</span></td>
                                          </tr>
                                          <tr>
                                              <td>4</td>
                                              <td class="txt-oflo">Medical Pro WP Theme</td>
                                              <td>TAX</td>
                                              <td class="txt-oflo">April 20, 2021</td>
                                              <td><span class="text-danger">-$24</span></td>
                                          </tr>
                                          <tr>
                                              <td>5</td>
                                              <td class="txt-oflo">Hosting press html</td>
                                              <td>SALE</td>
                                              <td class="txt-oflo">April 21, 2021</td>
                                              <td><span class="text-success">$24</span></td>
                                          </tr>
                                          <tr>
                                              <td>6</td>
                                              <td class="txt-oflo">Digital Agency PSD</td>
                                              <td>SALE</td>
                                              <td class="txt-oflo">April 23, 2021</td>
                                              <td><span class="text-danger">-$14</span></td>
                                          </tr>
                                          <tr>
                                              <td>7</td>
                                              <td class="txt-oflo">Helping Hands WP Theme</td>
                                              <td>MEMBER</td>
                                              <td class="txt-oflo">April 22, 2021</td>
                                              <td><span class="text-success">$64</span></td>
                                          </tr>
                                      </tbody>
                                  </table>
                              </div>
                          </div>
                      </div>
                  </div>
                  <!-- ============================================================== -->
                  <!-- Recent Comments -->
                  <!-- ============================================================== -->
                  <div class="row">
                      <!-- .col -->
                      <div class="col-md-12 col-lg-8 col-sm-12">
                          <div class="card white-box p-0">
                              <div class="card-body">
                                  <h3 class="box-title mb-0">Recent Comments</h3>
                              </div>
                              <div class="comment-widgets">
                                  <!-- Comment Row -->
                                  <div class="d-flex flex-row comment-row p-3 mt-0">
                                      <div class="p-2"><img src="https://therichpost.com/wp-content/uploads/2021/03/avatar2.png" alt="user" width="50" class="rounded-circle"></div>
                                      <div class="comment-text ps-2 ps-md-3 w-100">
                                          <h5 class="font-medium">James Anderson</h5>
                                          <span class="mb-3 d-block">Lorem Ipsum is simply dummy text of the printing and type setting industry.It has survived not only five centuries. </span>
                                          <div class="comment-footer d-md-flex align-items-center">
                                               <span class="badge bg-primary rounded">Pending</span>
                                               
                                              <div class="text-muted fs-2 ms-auto mt-2 mt-md-0">April 14, 2021</div>
                                          </div>
                                      </div>
                                  </div>
                                  <!-- Comment Row -->
                                  <div class="d-flex flex-row comment-row p-3">
                                      <div class="p-2"><img src="https://therichpost.com/wp-content/uploads/2021/03/avatar7.png" alt="user" width="50" class="rounded-circle"></div>
                                      <div class="comment-text ps-2 ps-md-3 active w-100">
                                          <h5 class="font-medium">Michael Jorden</h5>
                                          <span class="mb-3 d-block">Lorem Ipsum is simply dummy text of the printing and type setting industry.It has survived not only five centuries. </span>
                                          <div class="comment-footer d-md-flex align-items-center">
    
                                              <span class="badge bg-success rounded">Approved</span>
                                              
                                              <div class="text-muted fs-2 ms-auto mt-2 mt-md-0">April 14, 2021</div>
                                          </div>
                                      </div>
                                  </div>
                                  <!-- Comment Row -->
                                  <div class="d-flex flex-row comment-row p-3">
                                      <div class="p-2"><img src="https://therichpost.com/wp-content/uploads/2021/03/avatar7.png" alt="user" width="50" class="rounded-circle"></div>
                                      <div class="comment-text ps-2 ps-md-3 w-100">
                                          <h5 class="font-medium">Johnathan Doeting</h5>
                                          <span class="mb-3 d-block">Lorem Ipsum is simply dummy text of the printing and type setting industry.It has survived not only five centuries. </span>
                                          <div class="comment-footer d-md-flex align-items-center">
    
                                              <span class="badge rounded bg-danger">Rejected</span>
                                              
                                              <div class="text-muted fs-2 ms-auto mt-2 mt-md-0">April 14, 2021</div>
                                          </div>
                                      </div>
                                  </div>
                              </div>
                          </div>
                      </div>
                      <div class="col-lg-4 col-md-12 col-sm-12">
                          <div class="card white-box p-0">
                              <div class="card-heading">
                                  <h3 class="box-title mb-0">Chat Listing</h3>
                              </div>
                              <div class="card-body">
                                  <ul class="chatonline">
                                      <li>
                                          <div class="call-chat">
                                              <button class="btn btn-success text-white btn-circle btn me-1" type="button">
                                                  <i class="fas fa-phone"></i>
                                              </button>
                                              <button class="btn btn-info btn-circle btn" type="button">
                                                  <i class="far fa-comments text-white"></i>
                                              </button>
                                          </div>
                                          <a href="javascript:void(0)" class="d-flex align-items-center"><img
                                                  src="https://therichpost.com/wp-content/uploads/2021/03/avatar2.png" alt="user-img" class="img-circle">
                                              <div class="ms-2">
                                                  <span class="text-dark">Jassa <small
                                                          class="d-block text-success d-block">online</small></span>
                                              </div>
                                          </a>
                                      </li>
                                      <li>
                                          <div class="call-chat">
                                              <button class="btn btn-success text-white btn-circle btn me-1" type="button">
                                                  <i class="fas fa-phone"></i>
                                              </button>
                                              <button class="btn btn-info btn-circle btn" type="button">
                                                  <i class="far fa-comments text-white"></i>
                                              </button>
                                          </div>
                                          <a href="javascript:void(0)" class="d-flex align-items-center"><img
                                                  src="https://therichpost.com/wp-content/uploads/2021/03/avatar7.png" alt="user-img" class="img-circle">
                                              <div class="ms-2">
                                                  <span class="text-dark">Jassa
                                                       <small class="d-block text-warning">Away</small></span>
                                              </div>
                                          </a>
                                      </li>
                                      <li>
                                          <div class="call-chat">
                                              <button class="btn btn-success text-white btn-circle btn me-1" type="button">
                                                  <i class="fas fa-phone"></i>
                                              </button>
                                              <button class="btn btn-info btn-circle btn" type="button">
                                                  <i class="far fa-comments text-white"></i>
                                              </button>
                                          </div>
                                          <a href="javascript:void(0)" class="d-flex align-items-center"><img
                                                  src="https://therichpost.com/wp-content/uploads/2021/03/avatar7.png" alt="user-img" class="img-circle">
                                              <div class="ms-2">
                                                  <span class="text-dark">Jassa <small class="d-block text-danger">Busy</small></span>
                                              </div>
                                          </a>
                                      </li>
                                      <li>
                                          <div class="call-chat">
                                              <button class="btn btn-success text-white btn-circle btn me-1" type="button">
                                                  <i class="fas fa-phone"></i>
                                              </button>
                                              <button class="btn btn-info btn-circle btn" type="button">
                                                  <i class="far fa-comments text-white"></i>
                                              </button>
                                          </div>
                                          <a href="javascript:void(0)" class="d-flex align-items-center"><img
                                                  src="https://therichpost.com/wp-content/uploads/2021/03/avatar7.png" alt="user-img" class="img-circle">
                                              <div class="ms-2">
                                                  <span class="text-dark">Jassa <small class="d-block text-muted">Offline</small></span>
                                              </div>
                                          </a>
                                      </li>
                                      <li>
                                          <div class="call-chat">
                                              <button class="btn btn-success text-white btn-circle btn me-1" type="button">
                                                  <i class="fas fa-phone"></i>
                                              </button>
                                              <button class="btn btn-info btn-circle btn" type="button">
                                                  <i class="far fa-comments text-white"></i>
                                              </button>
                                          </div>
                                          <a href="javascript:void(0)" class="d-flex align-items-center"><img
                                                  src="https://therichpost.com/wp-content/uploads/2021/03/avatar7.png" alt="user-img"
                                                  class="img-circle">
                                              <div class="ms-2">
                                                  <span class="text-dark">Jassa <small class="d-block text-success">online</small></span>
                                              </div>
                                          </a>
                                      </li>
                                      <li>
                                          <div class="call-chat">
                                              <button class="btn btn-success text-white btn-circle btn me-1" type="button">
                                                  <i class="fas fa-phone"></i>
                                              </button>
                                              <button class="btn btn-info btn-circle btn" type="button">
                                                  <i class="far fa-comments text-white"></i>
                                              </button>
                                          </div>
                                          <a href="javascript:void(0)" class="d-flex align-items-center"><img
                                                  src="https://therichpost.com/wp-content/uploads/2021/03/avatar7.png" alt="user-img" class="img-circle">
                                              <div class="ms-2">
                                                  <span class="text-dark">Jassa<small class="d-block text-success">online</small></span>
                                              </div>
                                          </a>
                                      </li>
                                  </ul>
                              </div>
                          </div>
                      </div>
                      <!-- /.col -->
                  </div>
              </div>
              <!-- ============================================================== -->
              <!-- End Container fluid  -->
              <!-- ============================================================== -->
              <!-- ============================================================== -->
              <!-- footer -->
              <!-- ============================================================== -->
              <footer class="footer text-center"> 2021 © Rich Admin brought to you by <a
                      href="https://www.therichpost.com/">therichpost.com</a>
              </footer>
              <!-- ============================================================== -->
              <!-- End footer -->
              <!-- ============================================================== -->
          </div>
          <!-- ============================================================== -->
          <!-- End Page wrapper  -->
          <!-- ============================================================== -->
      </div>
      <!-- ============================================================== -->
      <!-- End Wrapper -->
      <!-- ============================================================== -->
    </body>
    </html>

     

    2. Now friends, please do the following steps because this is the most important:

    1. Please make “assets” folder inside public folder.

    2. Please download css files, fonts and script files from below url and please all that files inside “public/assets” folder.

    https://therichpost.com/bootstrap5admin.zip


    Now we are done friends and please run your Laravel 8 project and see the admin dashboard home page.  Also and If you have any kind of query or suggestion or any requirement then feel free to comment below.

    Note: Friends, I just tell the basic setup and things, you can change the code according to your requirements. For better understanding must watch video above.

    I will appreciate that if you will tell your views for this post. Nothing matters if your views will be good or bad.

    Jassa

    Thanks

  • Angular 12 PrimeNG Data Table with Export to Excel Button Working

    Angular 12 PrimeNG Data Table with Export to Excel Button Working

    Hello friends, welcome back to my blog. Today this blog post will tell you, Angular 12 PrimeNG Data Table with Export to Excel Button Working


    PrimeNG Data Table with Excel Button

    Angular 12&11 PrimeNG Data Table with Export to Excel Button Working
    Angular 12 PrimeNG Data Table with Export to Excel Button Working

    Angular 13 and Bootstrap 5 came and if you are new then you must check below two links:

    1. Angular13 Basic Tutorials
    2. PrimeNG
    3. Bootstrap 5

    Friends now I proceed onwards and here is the working code snippet and please use carefully this to avoid the mistakes:

    1. Firstly friends we need fresh angular 12 setup and for this we need to run below commands but if you already have angular 12 setup then you can avoid below commands. Secondly we should also have latest node version installed on our system:

    npm install -g @angular/cli 
    
    ng new angularprimeng //Create new Angular Project
    
    cd angularprimeng // Go inside the Angular Project Folder

    2. Now friends we need to run below commands into our project terminal to install primeng and excel file save modules into our angular application:

    npm install primeng --save
    
    npm install primeicons --save 
    
    npm install @angular/cdk --save
    
    npm i file-saver
    
    npm i xlsx
    
    npm install primeflex --save //for flex layout

    3. Now friends we just need to add below code into angularprimeng/src/app/app.component.html file to get final out on the web browser:

    <p-table [value]="sales">
        <ng-template pTemplate="caption">
            <div class="p-d-flex">
               
                <button type="button" pButton pRipple icon="pi pi-file-excel" (click)="exportExcel()" class="p-button-success p-mr-2"></button>
               
            </div>
        </ng-template>
        <ng-template pTemplate="header">
            <tr>
                
                <th pSortableColumn="brand">Brand <p-sortIcon field="brand"></p-sortIcon></th>
                <th>Last Year Sale</th>
                <th>This Year Sale</th>
                <th>Last Year Profit</th>
                <th>This Year Profit</th>
            </tr>
            
        </ng-template>
        <ng-template pTemplate="body" let-sale>
            <tr>
                <td>{{sale.brand}}</td>
                <td>{{sale.lastYearSale}}</td>
                <td>{{sale.thisYearSale}}</td>
                <td>{{sale.lastYearProfit}}</td>
                <td>{{sale.thisYearProfit}}</td>
            </tr>
        </ng-template>
    </p-table>

    4. Now friends we just need to add below code into angularprimeng/angular.json file:

     "styles": [
                  "src/styles.css",
                  "node_modules/primeng/resources/themes/saga-blue/theme.css",
                  "node_modules/primeng/resources/primeng.min.css",
                  "node_modules/primeflex/primeflex.css",
                  "node_modules/primeicons/primeicons.css",
                ],
    ...

    5. Now friends we just need to add below code into angularprimeng/src/app/app.component.ts file:

    ...
    export class AppComponent {
     ...
      ngOnInit() {
        this.sales = [
          { brand: 'Apple', lastYearSale: '51%', thisYearSale: '40%', lastYearProfit: '$54,406.00', thisYearProfit: '$43,342' },
          { brand: 'Samsung', lastYearSale: '83%', thisYearSale: '96%', lastYearProfit: '$423,132', thisYearProfit: '$312,122' },
          { brand: 'Microsoft', lastYearSale: '38%', thisYearSale: '5%', lastYearProfit: '$12,321', thisYearProfit: '$8,500' },
          { brand: 'Philips', lastYearSale: '49%', thisYearSale: '22%', lastYearProfit: '$745,232', thisYearProfit: '$650,323,' },
          { brand: 'Song', lastYearSale: '17%', thisYearSale: '79%', lastYearProfit: '$643,242', thisYearProfit: '500,332' },
          { brand: 'LG', lastYearSale: '52%', thisYearSale: ' 65%', lastYearProfit: '$421,132', thisYearProfit: '$150,005' },
          { brand: 'Sharp', lastYearSale: '82%', thisYearSale: '12%', lastYearProfit: '$131,211', thisYearProfit: '$100,214' },
          { brand: 'Panasonic', lastYearSale: '44%', thisYearSale: '45%', lastYearProfit: '$66,442', thisYearProfit: '$53,322' },
          { brand: 'HTC', lastYearSale: '90%', thisYearSale: '56%', lastYearProfit: '$765,442', thisYearProfit: '$296,232' },
          { brand: 'Toshiba', lastYearSale: '75%', thisYearSale: '54%', lastYearProfit: '$21,212', thisYearProfit: '$12,533' }
      ];
      
    }
    
    //excel button click functionality
    exportExcel() {
      import("xlsx").then(xlsx => {
          const worksheet = xlsx.utils.json_to_sheet(this.sales); // Sale Data
          const workbook = { Sheets: { 'data': worksheet }, SheetNames: ['data'] };
          const excelBuffer: any = xlsx.write(workbook, { bookType: 'xlsx', type: 'array' });
          this.saveAsExcelFile(excelBuffer, "sales");
      });
    }
    saveAsExcelFile(buffer: any, fileName: string): void {
      import("file-saver").then(FileSaver => {
        let EXCEL_TYPE =
          "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8";
        let EXCEL_EXTENSION = ".xlsx";
        const data: Blob = new Blob([buffer], {
          type: EXCEL_TYPE
        });
        FileSaver.saveAs(
          data,
          fileName + "_export_" + new Date().getTime() + EXCEL_EXTENSION
        );
      });
    }
    
    }

    6. Now friends we just need to add below code into angularprimeng/src/app/app.module.ts file:

    ...
    import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
    import { TableModule } from 'primeng/table';
    import { DropdownModule } from 'primeng/dropdown';
    import { ButtonModule } from 'primeng/button';
    
    @NgModule({
     ...
      imports: [
       ...
        BrowserAnimationsModule,
        TableModule,
        DropdownModule,
        ButtonModule
      ],
      ...

    Friends in the end must run ng serve command into your terminal to run the angular 12&11 project.

    Now we are done friends. If you have any kind of query, suggestion and new requirement then feel free to comment below.

    Note: Friends, In this post, I just tell the basic setup and things, you can change the code according to your requirements.

    I will appreciate that if you will tell your views for this post. Nothing matters if your views will be good or bad because with your views, I will make my next posts more good and helpful.

    Jassa

    Thanks