Category: Bootstrap 5

  • Angular 12 Sending data from Parent Component to Child Component Working

    Angular 12 Sending data from Parent Component to Child Component Working

    Hello friends, welcome back to my blog. Today in this blog post, I will tell you, Angular 12 Sending data from Parent Component to Child Component Working.

    Working Video
    Angular 12 Sending data from Parent Component to Child Component Working
    Angular 12 Sending data from Parent Component to Child Component Working

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

    1. Angular12 Beginner Tutorials

    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 parentchild //Create new Angular Project
    
    cd parentchild // Go inside the Angular Project Folder

    2. Now friends, here we need to run below commands into our project terminal to install bootstrap(good responsive looks):

    npm i bootstrap
    
    npm i @popperjs/core

    3. Now friends, here we need to add below  into our angular.json file:

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

    4. After done with the point 1 and point 2, you need to run below commands to create new parent, child components into your Angular 12 application:

    ng g c parent
    
    ng g c parent/child

    5. Now friends, we need to add below code into our project src/app/app-routing.module.ts file to make parent child component routing:

    import { NgModule } from '@angular/core';
    import { RouterModule, Routes } from '@angular/router';
    
    import { ParentComponent } from './parent/parent.component';
    import { ChildComponent } from './parent/child/child.component';
    const routes: Routes = [
      { path: 'parent', component: ParentComponent,
      children:[
        { path: 'child', component:ChildComponent }
      ]
    }
    ];
    
    @NgModule({
      imports: [RouterModule.forRoot(routes)],
      exports: [RouterModule]
    })
    export class AppRoutingModule { }
    

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

    <!-- Navigation -->
    <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="#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 ml-auto">
            <li class="nav-item active">
              <a class="nav-link" [routerLink]="['']">Home
              </a>
            </li>
            <li>
              <a class="nav-link" [routerLink]="['parent/child']">Child</a>
            </li>
          </ul>
        </div>
      </div>
    </nav>
    
    <!-- Page Content -->
    <div class="container mt-5">
    
      <!-- Heading Row -->
      <div class="row align-items-center my-5 mt-5">
        <div class="col-lg-12">
          <h1 class="font-weight-light">Therichpost.com</h1>
          Therichpost.com Therichpost.com Therichpost.com Therichpost.com
          Therichpost.com Therichpost.com Therichpost.com Therichpost.com
        </div>
       
        
      </div>
      <!-- /.row -->
      <div class="row align-items-center my-5 mt-5">
        <router-outlet></router-outlet>
      </div>
     
    
    </div>
    <!-- /.container -->

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

    import { Component, OnInit } from '@angular/core';
    
    @Component({
      selector: 'app-parent',
      templateUrl: './parent.component.html',
      styleUrls: ['./parent.component.css']
    })
    export class ParentComponent implements OnInit {
      //Declare array variable with some values
      data = [{name:"Therichpost"}, {name:"Ajay Malhotra"}];
      constructor() { }
    
      ngOnInit(): void {
      }
    
    }
    

    8. Now friends we just need to add below code into src/app/parent/parent.component.html file:

    <!--Child Component Selector-->
    
    <app-child [data]="data"></app-child>
        
    

    9. Now friends we just need to add below code into src/app/parent/child/child.component.ts file:

    import { Component, OnInit, Input } from '@angular/core';
    
    @Component({
      selector: 'app-child',
      templateUrl: './child.component.html',
      styleUrls: ['./child.component.css']
    })
    export class ChildComponent implements OnInit {
      @Input('data') masterName: any; 
      constructor() { }
    
      ngOnInit(): void {
      }
    
    }
    

    10. Now friends we just need to add below code into src/app/parent/child/child.component.html file:

    <p class="font-weight-bold">Child Works!</p>
    
    <p>Below List is coming from parent Component.</p>
    
    <ul>
        <li *ngFor="let item of masterName;">{{item.name}}</li>
    </ul>
    

    Now we are done friends. In the end don’t forget to run ng serve command to check the output(http://localhost:4200/). 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. For better live working experience, please check the video on the top.

    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

  • Reactjs Open PDF File inside Bootstrap 5 Modal POPUP

    Reactjs Open PDF File inside Bootstrap 5 Modal POPUP

    Hello friends, welcome back to my blog. Today in this blog post, I am going to show you, Reactjs Open PDF File inside Bootstrap 5 Modal POPUP.


    Working Video

    Reactjs Open PDF File inside Bootstrap 5 Modal POPUP
    Reactjs Open PDF File inside Bootstrap 5 Modal POPUP

    For reactjs new comers, please check the below link:

    Reactjs Basic Tutorials

    Bootstrap 5 Tutorials


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

    1. Firstly, we need fresh reactjs setup and for that, we need to run below commands into out terminal and also we should have latest node version installed on our system:

    npx create-react-app reactboot5
    
    cd reactboot5

    2. Now we need to run below commands into our project terminal to get bootstrap and related modules into our reactjs application:

    npm install bootstrap --save
    
    npm i @popperjs/core
    
    npm start //For start project again

    3. Finally for the main output, we need to add below code into our reactboot5/src/App.js file or if you have fresh setup then you can replace reactboot5/src/App.js file code with below code:

    //importing bootstrap 5 css
    import 'bootstrap/dist/css/bootstrap.min.css';
    import 'bootstrap/dist/js/bootstrap.min.js';
    function App() {
      return (
        <div className="App">
          
            <div className="container mt-5">
              <h1 className="text-center">Therichpost.com</h1>
            </div>
            <div class="container p-5">
      
      <button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#exampleModal">
        Open PDF
      </button>
      
     
      <div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
        <div class="modal-dialog modal-xl">
          <div class="modal-content" style={{height:"500px"}}>
            <div class="modal-header">
              <h5 class="modal-title text-danger" id="exampleModalLabel">PDF</h5>
              <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
            </div>
            <div class="modal-body">
          <iframe
          src="https://therichpost.com/sample.pdf#toolbar=0&navpanes=0&scrollbar=0"
          frameBorder="0"
          scrolling="auto"
          height="100%"
          width="100%"
      ></iframe>
            </div>
            <div class="modal-footer">
              <button type="button" class="btn btn-warning" data-bs-dismiss="modal">Close</button>
            </div>
          </div>
        </div>
      </div>
      </div>
         
          
        </div>
      );
    }
    
    export default App;

    Now we are done friends. 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.

    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

  • How to open pdf file inside bootstrap 5 modal popup in angular 12 application?

    How to open pdf file inside bootstrap 5 modal popup in angular 12 application?

    Hello friends, welcome back to my blog. Today in this blog post, I am going to tell you, How to open pdf file inside bootstrap 5 modal popup in angular 12 application?

    Here is the tutorial link for update angular version to 12: Update Angular 11 to Angular 12

    Working Video

    Guy’s here are the more demos related to Angular 12 with Bootstrap 5:

    1. Bootstrap 5 Popover working in Angular 12
    2. Bootstrap 5 Tooltip working in Angular 12
    3. Bootstrap5 Modal with Forms in Angular 12


    How to open pdf file inside bootstrap 5 modal popup in angular 12 application?
    How to open pdf file inside bootstrap 5 modal popup in angular 12 application?

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

    1. Angular 12 Tutorials
    2. Angular12 Free Templates
    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 angularboot5 //Create new Angular Project
    
    cd angularboot5 // Go inside the Angular Project Folder

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

    npm install bootstrap
    
    npm i @popperjs/core

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

    <div class="container p-5">
      <!-- Button trigger modal -->
      <button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#exampleModal">
        Open PDF
      </button>
      
      <!-- Modal -->
      <div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
        <div class="modal-dialog modal-xl">
          <div class="modal-content">
            <div class="modal-header">
              <h5 class="modal-title text-danger" id="exampleModalLabel">PDF</h5>
              <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
            </div>
            <div class="modal-body">
          <iframe
          src="https://therichpost.com/sample.pdf#toolbar=0&navpanes=0&scrollbar=0"
          frameBorder="0"
          scrolling="auto"
          height="100%"
          width="100%"
      ></iframe>
            </div>
            <div class="modal-footer">
              <button type="button" class="btn btn-warning" data-bs-dismiss="modal">Close</button>
            </div>
          </div>
        </div>
      </div>
      </div>

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

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

    Friends in the end must run ng serve command into your terminal to run the angular 12 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

  • Vue 3 Open PDF file inside Bootstrap 5 Modal POPUP

    Vue 3 Open PDF file inside Bootstrap 5 Modal POPUP

    Hello friends, welcome back to my blog. Today in this blog post, I am going to show you, Vue 3 Open PDF file inside Bootstrap 5 Modal POPUP.

    Bootstrap 5 in Vuejs

    Guy’s here you can see more Vue 3 Bootstrap 5 working example:

    1. Bootstrap 5 Popover working in Vue 3.
    2. Bootstrap 5 Tooltip working in Vue 3.
    3. Bootstrap5 Popup Modal with Forms in Vue 3.


    Vue 3 Open PDF file inside Bootstrap 5 Modal POPUP
    Vue 3 Open PDF file inside Bootstrap 5 Modal POPUP

    Vue 3 and Bootstrap 5 came and if you are new then you must check below two links:

    1. Vuejs
    2. Bootstrap 5

    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 vue 3 setup and for this we need to run below commands . Secondly we should also have latest node version installed on our system. With below we will have  bootstrap 5 modules in our Vue 3 application:

    npm install -g @vue/cli
    
    vue create vueboot5
    
    cd vueboot5
    
    npm i bootstrap
    
    npm run serve //http://localhost:8080/
    
    

    2. Now friends we need to add below code into src/App.vue file to check the final output on browser:

    <template>
     <div class="container p-5">
    <!-- Button trigger modal -->
    <button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#exampleModal">
      Open PDF
    </button>
    
    <!-- Modal -->
    <div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
      <div class="modal-dialog modal-xl">
        <div class="modal-content">
          <div class="modal-header">
            <h5 class="modal-title text-danger" id="exampleModalLabel">PDF</h5>
            <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
          </div>
          <div class="modal-body">
        <iframe
        src="https://therichpost.com/sample.pdf#toolbar=0&navpanes=0&scrollbar=0"
        frameBorder="0"
        scrolling="auto"
        height="100%"
        width="100%"
    ></iframe>
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-warning" data-bs-dismiss="modal">Close</button>
          </div>
        </div>
      </div>
    </div>
    </div>
    </template>
    <script>
    //importing bootstrap 5
    import "bootstrap/dist/css/bootstrap.min.css";
    import "bootstrap/dist/js/bootstrap.min.js";
    export default {
     
    }
    </script>
    <style>
    .modal-content
    {
      height:600px
    }
    </style>

    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.

    Note: Friends, 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.

    Jassa

    Thanks

  • How to integrate google pay in Angular 12?

    How to integrate google pay in Angular 12?

    Hello friends, welcome back to my blog. Today in this blog post, I am going to tell you, How to integrate google pay in Angular 12?

    Angular 12 Demos

    Guy’s here are the more demos related to Angular 12 with Bootstrap 5:

    1. Bootstrap 5 Popover working in Angular 12
    2. Bootstrap 5 Tooltip working in Angular 12
    3. Bootstrap5 Modal with Forms in Angular 12


    How to integrate google pay in Angular 12
    How to integrate google pay in Angular 12?

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

    1. Angular 12 Tutorials
    2. Angular12 Free Templates
    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 angulardemo //Create new Angular Project
    
    cd angulardemo // Go inside the Angular Project Folder

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

    npm install bootstrap
    
    npm install @google-pay/button-angular

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

    <div class="container p-5">
    <!--Button Settings(optional) -->
    <form class="top-bottom mb-5">
      <div class="mb-3">
      <label class="form-label">Button color</label>
        
        <select class="form-control" name="button-color" [(ngModel)]="buttonColor">
          <option value="default">default</option>
          <option value="black">black</option>
          <option value="white">white</option>
        </select>
     
    </div>
    <div class="mb-3">
      <label class="form-label">
        Button type</label>
        <select class="form-control" name="button-type" [(ngModel)]="buttonType">
          <option value="buy">buy</option>
          <option value="plain">plain</option>
          <option value="donate">donate</option>
        </select>
     
      </div>
      <div class="mb-3 form-check">
     
        
        
        <input class="form-check-input" name="button-custom" type="checkbox" [(ngModel)]="isCustomSize">
        <label class="form-check-label" for="exampleCheck1">Custom button size</label>
      </div>
      <div class="mb-3">
      <label class="form-label">
        <span>Button width <span class="value">({{buttonWidth}}px)</span></span></label>
        <input class="form-control"
          name="button-width"
          type="range"
          min="160"
          max="800"
          [(ngModel)]="buttonWidth"
          [disabled]="!isCustomSize"
        />
      
      </div>
      <div class="mb-3">
      <label class="form-label">
        <span>Button height <span class="value">({{buttonHeight}}px)</span></span></label>
        <input class="form-control"
          name="button-height"
          type="range"
          min="40"
          max="100"
          [(ngModel)]="buttonHeight"
          [disabled]="!isCustomSize"
        />
      
      </div>
    </form>
    <!--Button Settings -->
    <div class="demo">
      <google-pay-button environment="TEST" [buttonColor]="buttonColor" [buttonType]="buttonType"
        [buttonSizeMode]="isCustomSize ? 'fill' : 'static'" [paymentRequest]="paymentRequest" [style.width.px]="buttonWidth"
        [style.height.px]="buttonHeight" (loadpaymentdata)="onLoadPaymentData($event)"></google-pay-button>
    </div>
    </div>

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

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

    5. Now friends we just need to add below code into src/app/app.component.ts file for button click and other functionalities:

    ...
    export class AppComponent {
    ...
          
    
          //google pay button settings
          buttonColor = "black";
          buttonType = "buy";
          isCustomSize = false;
          buttonWidth = 240;
          buttonHeight = 40;
          isTop = window === window.top;
        
          paymentRequest = {
            apiVersion: 2,
            apiVersionMinor: 0,
            allowedPaymentMethods: [
              {
                type: "CARD",
                parameters: {
                  allowedAuthMethods: ["PAN_ONLY", "CRYPTOGRAM_3DS"],
                  allowedCardNetworks: ["AMEX", "VISA", "MASTERCARD"]
                },
                tokenizationSpecification: {
                  type: "PAYMENT_GATEWAY",
                  parameters: {
                    gateway: "example",
                    gatewayMerchantId: "exampleGatewayMerchantId"
                  }
                }
              }
            ],
            merchantInfo: {
              merchantId: "12345678901234567890",
              merchantName: "Demo Merchant"
            },
            transactionInfo: {
              totalPriceStatus: "FINAL",
              totalPriceLabel: "Total",
              totalPrice: "100.00",
              currencyCode: "USD",
              countryCode: "US"
            }
          };
        
          onLoadPaymentData(event) {
            console.log("load payment data", event.detail);
          }
    }

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

    ...
    import { GooglePayButtonModule } from "@google-pay/button-angular";
    @NgModule({
      ...
      imports: [
     ...
        GooglePayButtonModule
      ],
      providers: [],
      bootstrap: [AppComponent]
    })
    export class AppModule { }
    

    Friends in the end must run ng serve command into your terminal to run the angular 12 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

  • How pass json array from service to component in Angular 12?

    How pass json array from service to component in Angular 12?

    Hello to all welcome back on my blog therichpost.com. Today in this blog post, I am going to tell you, How pass json array from service to component in Angular 12?

    Working Video
    How pass json array from service to component in Angular 12?
    How pass json array from service to component in Angular 12?

    Guy’s Angular 12 came and if you are new in Angular 12 and WordPress then please check the below links:

    1. Angular 12 Tutorials

    Guy’s here is working code snippet and please follow it 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 angulardemo //Create new Angular Project
    
    cd angulardemo // Go inside the Angular Project Folder

    2. Now guy’s, here we need to run below commands into our project terminal to install bootstrap 5 module for styling and good looks into our angular application(optional) and create services files:

    npm install bootstrap
    
    npm i @popperjs/core
    
    ng g service servicedata //services

    3. Now guy’s, now we need to add below code into our angulardemo/angular.json file to add bootstrap style:

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

    4. Now guy’s, now we need to add below code into our angulardemo/src/app/servicedata.service.ts file to call json data:

    import { Injectable } from '@angular/core';
    
    @Injectable({
      providedIn: 'root'
    })
    export class ServicedataService {
      public userData =
      [
        {id: '1', first: 'Jassa', last:'Rich'},
        {id: '2', first: 'Harjas', last:'Malhotra'},
      ];
      constructor() { }
     
    }
    

    5. Now guys, now we need to add below code into our angulardemo/src/app/app.component.html file to get final output on browser:

    <table class="table table-hover table-bordered">
      <thead>
        <tr>
          <th scope="col">ID</th>
          <th scope="col">First</th>
          <th scope="col">Last</th>
         
        </tr>
      </thead>
      <tbody>
        <tr *ngFor="let user of usersdata">
          <th scope="row">{{user.id}}</th>
          <td>{{user.first}}</td>
          <td>{{user.last}}</td>
         
        </tr>
       
        
      </tbody>
    </table>

    6. Now guys, now we need to add below code into our angulardemo/src/app/app.component.ts file:

    import { Component } from '@angular/core';
    import { ServicedataService } from './servicedata.service';
    @Component({
      selector: 'app-root',
      templateUrl: './app.component.html',
      styleUrls: ['./app.component.css']
    })
    export class AppComponent {
     usersdata:any;
      constructor(private servicedata: ServicedataService) {}
      ngOnInit(){
              this.usersdata = this.servicedata.userData;
      }
    }

    Guy’s in the end please run ng serve command to check the out on browser(localhost:4200) and if you will have any query then feel free to comment below.

    Guy’s 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.

  • How to change button text on click function in Angular 12?

    How to change button text on click function in Angular 12?

    Hello friends, welcome back to my blog. Today in this blog post, I am going to tell you, How to change button text on click function in Angular 12?

    Here is the tutorial link for update angular version to 12: Update Angular 11 to Angular 12

    Angular 12 Demos

    Guy’s here are the more demos related to Angular 12 with Bootstrap 5:

    1. Bootstrap 5 Popover working in Angular 12
    2. Bootstrap 5 Tooltip working in Angular 12
    3. Bootstrap5 Modal with Forms in Angular 12


    How to change button text on click function in Angular 12?
    How to change button text on click function in Angular 12?

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

    1. Angular 12 Tutorials
    2. Angular12 Free Templates
    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 angulardemo //Create new Angular Project
    
    cd angulardemo // Go inside the Angular Project Folder

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

    npm install bootstrap

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

    <div class="container  text-center mt-5 mb-5">
      <button class="btn btn-primary me-3" (click)="changeText()">{{btnVal}}</button>
    </div>

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

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

    5. Now friends we just need to add below code into src/app/app.component.ts file for button click functionality:

    ...
    export class AppComponent {
    ...
    
    //button text variable
    btnVal = "Button";
    
    //button click function
    changeText()
          {
            this.btnVal = "Clicked!!"
          }
    }

    Friends in the end must run ng serve command into your terminal to run the angular 12 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

  • Laravel 8 Multiple Image Upload Preview Save inside Folder Working Functionality

    Laravel 8 Multiple Image Upload Preview Save inside Folder Working Functionality

    Hello guy’s welcome back to my blog. Today in this blog post we will do, Laravel 8 Multiple Image Upload Preview Save inside Folder Working Functionality.

    Live working video
    Laravel 8 Multiple Image Upload Preview Save inside Folder Working Functionality
    Laravel 8 Multiple Image Upload Preview Save inside Folder Working Functionality

    Guys if you are new in Laravel 8 the please check below links:

    1. Laravel Basics Tutorial for beginners
    2. Bootstrap 5

    Guy’s here is the working code snippet and please use carefully:

    1. Guy’s very first please create file `image-upload.blade.php` inside projectname/resources/views folder and add below code:

    <!doctype html>
    <html lang="en">
    
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
        <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet">
    
        <title>Laravel Image Upload</title>
        <style>
    
            .imgPreview img {
                padding: 8px;
                max-width: 100px;
            } 
        </style>
    </head>
    
    <body>
    
        <div class="container mt-5">
            <h3 class="text-center mb-5">Laravel 8 Multiple Image Upload Preview Working Functionality</h3>
            <form action="{{route('imageUpload')}}" method="post" enctype="multipart/form-data">
                @csrf
                @if ($message = Session::get('success'))
                    <div class="alert alert-success">
                        <strong>{{ $message }}</strong>
                    </div>
                @endif
    
                @if (count($errors) > 0)
                    <div class="alert alert-danger">
                        <ul>
                            @foreach ($errors->all() as $error)
                            <li>{{ $error }}</li>
                            @endforeach
                        </ul>
                    </div>
                @endif
    
                <div class="user-image mb-3 text-center">
                    <div class="imgPreview"> </div>
                </div>            
                <div class="mb-3">
                    <label for="exampleFormControlInput1" class="form-label">Choose Images</label>
                    <input type="file" class="form-control" name="imageFile[]" id="images" multiple="multiple">
                    </div>
               
    
                <button type="submit" name="submit" class="btn btn-primary mt-4">
                    Upload Images
                </button>
            </form>
        </div>
      
        <!-- jQuery -->
        <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
        <script>
            $(function() {
            // Multiple images preview with JavaScript
            var multiImgPreview = function(input, imgPreviewPlaceholder) {
    
                if (input.files) {
                    var filesAmount = input.files.length;
    
                    for (i = 0; i < filesAmount; i++) {
                        var reader = new FileReader();
    
                        reader.onload = function(event) {
                            $($.parseHTML('<img>')).attr('src', event.target.result).appendTo(imgPreviewPlaceholder);
                        }
    
                        reader.readAsDataURL(input.files[i]);
                    }
                }
    
            };
    
            $('#images').on('change', function() {
                multiImgPreview(this, 'div.imgPreview');
            });
            });    
        </script>
    </body>
    </html>

    2. Guy’s now add below code inside projectname/routes/web.php file for routing:

    ...
    Route::get('/image-upload', [App\Http\Controllers\HomeController::class, 'createForm']);
    Route::post('/image-upload', [App\Http\Controllers\HomeController::class, 'fileUpload'])->name('imageUpload');
    ...

    3. Guy’s now add below code inside projectname/app/Http/Controllers/HomeController.php file to call the save folder functionality:

    <?php
    
    ...
    
    class HomeController extends Controller
    {
         ...
          public function createForm(){
            return view('image-upload');
          }
    
          public function fileUpload(Request $req){
            $req->validate([
              'imageFile' => 'required',
              'imageFile.*' => 'mimes:jpeg,jpg,png,gif,csv,txt,pdf|max:2048'
            ]);
        
            if($req->hasfile('imageFile')) {
                foreach($req->file('imageFile') as $file)
                {
                    $name = $file->getClientOriginalName();
                    $file->move(public_path().'/uploads/', $name);  
                    $imgData[] = $name;  
                }
        
               return back()->with('success', 'File has successfully uploaded!');
            }
          }
        
    }
    

    4. Guy’s in the end we need to create `uploads` folder inside projectname/public folder to save the uploaded files.

    Guy’s now we are done and please run php artisan serve command in your Laravel 8 project and see the working(http://127.0.0.1:8000/image-upload) .

    Friends 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.

  • How to include html file in angular 12 component?

    How to include html file in angular 12 component?

    Hello friends, welcome back to my blog. Today in this blog post, I am going to tell you, How to include html file in angular 12 component?

    Working Video
    How to include html file in angular 12 component?
    How to include html file in angular 12 component?

    Guy’s Angular 12 came . if you are new then you must check below two links:

    1. Angular12 Basic Tutorials
    2. Angular Free Templates

    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 also , bootstrap 5 and html loader modules. Secondly we should also have latest node version installed on our system:

    npm install -g @angular/cli 
    
    ng new angulardemo //Create new Angular Project
    
    cd angulardemo // Go inside the Angular Project Folder
    
    npm add html-loader 
    
    npm i bootstrap

    2. Guy’s now we need to create `typings.d.ts` file inside angulardemo/src folder and add below code inside it:

    /* SystemJS module definition */
    declare module '*html'
    {
      const value:string;
      export default value
    }

    3. Guy’s now add below code inside angulardemo/tsconfig.json file to call typing.d.ts file:

    {
      ...
        "typeRoots": [ 
        ...
        "../src/typings.d.ts" ],
       ...
    }

    4. Now guy’s create `testing.component.html` file inside angulardemo/src/app folder and add below html code inside:

    <div class="container">
        <h3 class="p-5 text-center text-decoration-underline">I am coming from test.component.html file:</h3>
        <div class="row row-cols-2 row-cols-lg-5 g-2 g-lg-3">
          <div class="col">
            <div class="p-3 border bg-light">Row column</div>
          </div>
          <div class="col">
            <div class="p-3 border bg-light">Row column</div>
          </div>
          <div class="col">
            <div class="p-3 border bg-light">Row column</div>
          </div>
          <div class="col">
            <div class="p-3 border bg-light">Row column</div>
          </div>
          <div class="col">
            <div class="p-3 border bg-light">Row column</div>
          </div>
          
        </div>
      </div>

    5. Now guy’s add below code inside angulardemo/src/app/app.component.html file:

    <!--Call File-->
    
    <div innerHtml="{{test}}"></div>

    6. Now guy’s add below code inside angulardemo/src/app/app.component.ts file:

    ...
    export class AppComponent {
     ...
      test:any
      constructor() {
        this.test = require('html-loader!./testing.component.html');
        this.test = this.test.default;
      }
    
    }

    Now we are done friends. and please ng serve command to see the output. 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. For better live working experience, please check the video on the top.

    Chamkila

    Thanks

  • Laravel 8 Datatable with Copy Excel Csv Pdf Print Buttons Functionalities

    Laravel 8 Datatable with Copy Excel Csv Pdf Print Buttons Functionalities

    Hello friends, welcome back on blog. Today in this blog post, I am going to tell you, Laravel 8 Datatable with Copy Excel Csv Pdf Print Buttons Functionalities.

    Working Demo
    Laravel 8 Datatable with Copy Excel Csv Pdf Print Buttons Functionalities
    Laravel 8 Datatable with Copy Excel Csv Pdf Print Buttons Functionalities

    Guys if you are new in Laravel8 the please check below link for Laravel basics information:

    Laravel Basics Tutorial for beginners

    Bootstrap 5

    Datatable


    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>Ecommerce Template</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- Template Main CSS & JS File -->
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
     
      <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.25/css/jquery.dataTables.css">
      <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet">
      <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.min.js"></script>
        <script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.25/js/jquery.dataTables.js"></script>
        <script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/buttons/1.7.1/js/dataTables.buttons.min.js"></script>
        <script type="text/javascript" charset="utf8" src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
        <script type="text/javascript" charset="utf8" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/pdfmake.min.js"></script>
        <script type="text/javascript" charset="utf8" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/vfs_fonts.js"></script>
        <script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/buttons/1.7.1/js/buttons.html5.min.js"></script>
        <script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/buttons/1.7.1/js/buttons.print.min.js"></script>
    
      <script>
        jQuery(document).ready(function($) {
          $('#example').DataTable(
            {
            dom: 'Bfrtip',
            buttons: [
                        'copy',
                        'excel',
                        'csv',
                        'pdf',
                        'print'
                    ],
            }
          );
         
        } );
        </script>
      
    </head>
    <body>
    <div class="container p-5">
    <table id="example" class="table table-striped table-hover table-bordered">
            <thead>
                <tr>
                    <th>Name</th>
                    <th>Position</th>
                    <th>Office</th>
                    <th>Age</th>
                    <th>Start date</th>
                    <th>Salary</th>
                  
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>Tiger Nixon</td>
                    <td>System Architect</td>
                    <td>Edinburgh</td>
                    <td>61</td>
                    <td>2011/04/25</td>
                    <td>$320,800</td>
                   
                </tr>
                <tr>
                    <td>Garrett Winters</td>
                    <td>Accountant</td>
                    <td>Tokyo</td>
                    <td>63</td>
                    <td>2011/07/25</td>
                    <td>$170,750</td>
                   
                </tr>
                <tr>
                    <td>Ashton Cox</td>
                    <td>Junior Technical Author</td>
                    <td>San Francisco</td>
                    <td>66</td>
                    <td>2009/01/12</td>
                    <td>$86,000</td>
                    
                </tr>
                <tr>
                    <td>Cedric Kelly</td>
                    <td>Senior Javascript Developer</td>
                    <td>Edinburgh</td>
                    <td>22</td>
                    <td>2012/03/29</td>
                    <td>$433,060</td>
                   
                </tr>
                <tr>
                    <td>Airi Satou</td>
                    <td>Accountant</td>
                    <td>Tokyo</td>
                    <td>33</td>
                    <td>2008/11/28</td>
                    <td>$162,700</td>
                   
                </tr>
                <tr>
                    <td>Brielle Williamson</td>
                    <td>Integration Specialist</td>
                    <td>New York</td>
                    <td>61</td>
                    <td>2012/12/02</td>
                    <td>$372,000</td>
                   
                </tr>
                <tr>
                    <td>Herrod Chandler</td>
                    <td>Sales Assistant</td>
                    <td>San Francisco</td>
                    <td>59</td>
                    <td>2012/08/06</td>
                    <td>$137,500</td>
                 
                </tr>
                <tr>
                    <td>Rhona Davidson</td>
                    <td>Integration Specialist</td>
                    <td>Tokyo</td>
                    <td>55</td>
                    <td>2010/10/14</td>
                    <td>$327,900</td>
                    
                </tr>
                <tr>
                    <td>Colleen Hurst</td>
                    <td>Javascript Developer</td>
                    <td>San Francisco</td>
                    <td>39</td>
                    <td>2009/09/15</td>
                    <td>$205,500</td>
                   
                </tr>
                <tr>
                    <td>Sonya Frost</td>
                    <td>Software Engineer</td>
                    <td>Edinburgh</td>
                    <td>23</td>
                    <td>2008/12/13</td>
                    <td>$103,600</td>
                    
                </tr>
                <tr>
                    <td>Jena Gaines</td>
                    <td>Office Manager</td>
                    <td>London</td>
                    <td>30</td>
                    <td>2008/12/19</td>
                    <td>$90,560</td>
                    
                </tr>
                <tr>
                    <td>Quinn Flynn</td>
                    <td>Support Lead</td>
                    <td>Edinburgh</td>
                    <td>22</td>
                    <td>2013/03/03</td>
                    <td>$342,000</td>
                    
                </tr>
                <tr>
                    <td>Charde Marshall</td>
                    <td>Regional Director</td>
                    <td>San Francisco</td>
                    <td>36</td>
                    <td>2008/10/16</td>
                    <td>$470,600</td>
                   
                </tr>
                <tr>
                    <td>Haley Kennedy</td>
                    <td>Senior Marketing Designer</td>
                    <td>London</td>
                    <td>43</td>
                    <td>2012/12/18</td>
                    <td>$313,500</td>
                   
                </tr>
                
            </tbody>
            <tfoot>
                <tr>
                    <th>Name</th>
                    <th>Position</th>
                    <th>Office</th>
                    <th>Age</th>
                    <th>Start date</th>
                    <th>Salary</th>
                </tr>
            </tfoot>
        </table>
    
    </div>
    
    </body>
    </html>

    Now we are done friends and please run your Laravel 8 project and see the working site 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