angular Archives - Ebhor.com Read The Latest Post Java, Css, Html, Php learning articles Fri, 22 Sep 2023 09:45:15 +0000 en-US hourly 1 https://wordpress.org/?v=6.5.2 https://www.ebhor.com/wp-content/uploads/2021/05/ebhor_logo_100x.jpg angular Archives - Ebhor.com 32 32 Angular Spring Boot showing data in table https://www.ebhor.com/angular-spring-boot-showing-data-in-table/ Fri, 22 Sep 2023 04:01:00 +0000 https://www.ebhor.com/?p=13590 Here we will use Angular and Spring boot to show data in HTML table. Spring boot To start a spring project go to https://start.spring.io/ For this project we selected Click on generate to download spring boot project then extract then project zip file and move to your project location. Eclipse IDE is used to develop ... Read more

The post Angular Spring Boot showing data in table appeared first on Ebhor.com.

]]>
Here we will use Angular and Spring boot to show data in HTML table.

Spring boot

To start a spring project go to https://start.spring.io/

For this project we selected

  1. Java 1.8
  2. Spring Web
  3. Spring Data JPA
  4. MySQL Driver
Spring Initializer to start spring boot project
Fig: Spring Initializer to start spring boot project

Click on generate to download spring boot project then extract then project zip file and move to your project location.

Eclipse IDE is used to develop spring boot project.

How to import maven project in Eclipse

  1. Open Eclipse
  2. Click on File
  3. Click on import
  4. On select import wizard select Maven
  5. Click on existing maven Project
  6. Click on next
  7. Browse folder
  8. Click on finish

Now maven project is imported to eclipse.

Updation of project is required for that follw this steps

  1. Right click on project in project Explorer
  2. Select Maven Option
  3. Update Maven
Spring Boot Project Explorer
Spring Boot Project Explorer

ExampleApplication.java

package com.ebhor.example;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class ExampleApplication {

	public static void main(String[] args) {
		SpringApplication.run(ExampleApplication.class, args);
	}

}

POM.xml


	4.0.0
	
		org.springframework.boot
		spring-boot-starter-parent
		2.7.2
		 
	
	com.ebhor
	mvc
	0.0.1-SNAPSHOT
	war
	mvc
	Spring MVC Example
	
		1.8
	
	
		
			org.springframework.boot
			spring-boot-starter-web
		
		
			org.springframework.boot
			spring-boot-starter-data-jpa
		
		
			org.springframework.boot
			spring-boot-starter-tomcat
			provided
		
		
			org.springframework.boot
			spring-boot-starter-test
			test
		
		
			mysql
			mysql-connector-java
			runtime
		
	
	
		
			
				org.springframework.boot
				spring-boot-maven-plugin
			
		
	

Application.properties

Here we configured spring datasource to connect with MySql Database.

spring.datasource.url=jdbc:mysql://localhost:3306/ebhor
spring.datasource.username=root
spring.datasource.password=
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.jpa.hibernate.ddl-auto=update
spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect

EmployeeController.java

EmployeeController is used to fetch employee list from EmployeeService and send it to client using RestController.

@CrossOrigin(origins = “http://localhost:4200”) annotation is used to allow access this url to angular project.

package com.ebhor.example.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ebhor.example.entity.Employee;
import com.ebhor.example.service.EmployeeService;

@RestController
@CrossOrigin(origins = "http://localhost:4200")
public class EmployeeController {
	@Autowired
	EmployeeService employeeService;
	@GetMapping("/")
	public Iterable getEmployess() {
		return employeeService.getEmployees();
	}
}

Employee.java

This is an Employee entity class which maps with database table employee.

package com.ebhor.example.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity
@Table(name = "employee")
public class Employee {

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "id")
	private int id;
	@Column(name = "name", nullable = false)
	private String name;
	@Column(name = "designation", nullable = false)
	private String designation;
	@Column(name = "mobileno", nullable = false)
	private String mobileNo;
	@Column(name = "mailid", nullable = false)
	private String mailId;
	@Column(name = "department", nullable = false)
	private String department;

	public Employee() {
	}

	public Employee(int id, String name, String designation, String mobileNo, String mailId, String department) {
		super();
		this.id = id;
		this.name = name;
		this.designation = designation;
		this.mobileNo = mobileNo;
		this.mailId = mailId;
		this.department = department;
	}

	@Override
	public String toString() {
		return "Employee [id=" + id + ", name=" + name + ", designation=" + designation + ", mobileNo=" + mobileNo
				+ ", mailId=" + mailId + ", department=" + department + "]";
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDesignation() {
		return designation;
	}

	public void setDesignation(String designation) {
		this.designation = designation;
	}

	public String getMobileNo() {
		return mobileNo;
	}

	public void setMobileNo(String mobileNo) {
		this.mobileNo = mobileNo;
	}

	public String getMailId() {
		return mailId;
	}

	public void setMailId(String mailId) {
		this.mailId = mailId;
	}

	public String getDepartment() {
		return department;
	}

	public void setDepartment(String department) {
		this.department = department;
	}

}

EmployeeService.java

EmployeeServices fetch data from EmployeeDAO and pass to EmployeeController

package com.ebhor.example.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ebhor.example.dao.EmployeeDAO;
import com.ebhor.example.entity.Employee;
@Service
public class EmployeeService {
	@Autowired
	public EmployeeDAO employeeDAO;
	public Iterable getEmployees() {
		return employeeDAO.findAll();
	}
}

EmployeeDAO.java

Interface EmployeeDAO extends to CrudRepository which provice access to database table.

package com.ebhor.example.dao;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
import com.ebhor.example.entity.Employee;
@Repository
public interface EmployeeDAO extends CrudRepository{
}

To test our spring boot project you can call url using browser or Postman API

Postman API
Fig: Postman API

Angular Project

Visual studio code IDE is used to develop this project.

npm -v is 8.5.5
ng –version
Package and Version
@angular-devkit/architect 0.1303.7 (cli-only)
@angular-devkit/core 13.3.7 (cli-only)
@angular-devkit/schematics 13.3.7 (cli-only)
@schematics/angular 13.3.7 (cli-only)

Angular Commands

  1. To create new project => ng new angularapp1
  2. Generate service => ng g s employee
  3. Start server => ng serve
Angular Project Explorer
Fig: Angular Project Explorer

index.html

Remove all existing body content.

add Bootstrap CDN in head section




  
  Angularapp1
  
  
  
  


  

app.module.ts

Here HttpClientModule is added in imports.

import { NgModule } from '@angular/core';
import {HttpClientModule} from '@angular/common/http';
import { BrowserModule } from '@angular/platform-browser';

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';


@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,
    HttpClientModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

Employee.ts

This file contains employee interface that is having all fields of employee.

export interface Employee{
    id: number,
    name: string,
    designation:string,
    mobileNo:string,
    mailId:string,
    department:string
}

employee.service.ts

This file contains a method getEmployees() to get the employee data from specified url.

import { HttpClient, HttpErrorResponse } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable, throwError } from 'rxjs';
import { catchError, retry } from 'rxjs/operators';
import { Employee } from './employee';
@Injectable({
  providedIn: 'root'
})
export class EmployeeService {
  private url = "http://localhost:8080/"
  constructor(private http: HttpClient) { }
  getEmployees(): Observable {
    return this.http.get(this.url)
      .pipe(
        retry(2),
        catchError(this.handleError)
      );
  }
  private handleError(error: HttpErrorResponse) {
    if (error.status === 0) {
      // A client-side or network error occurred. Handle it accordingly.
      console.error('An error occurred:', error.error);
    } else {
      // The backend returned an unsuccessful response code.
      // The response body may contain clues as to what went wrong.
      console.error(
        `Backend returned code ${error.status}, body was: `, error.error);
    }
    // Return an observable with a user-facing error message.
    return throwError(() => new Error('Something bad happened; please try again later.'));
  }
}

app.component.ts

This fill access the EmployeeService class and get data of Employee to employess variable

import { Component, OnInit } from '@angular/core';
import { EmployeeService } from './employee.service';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {
  public employees: any;
  constructor(private _employeeService: EmployeeService) { }
  ngOnInit(): void {
    this.employees = this._employeeService.getEmployees()
      .subscribe(data => this.employees = data);
  }


}

app.component.html:

This is HTML file to show employee data

ngFor is used to loop employees and interpolation is used to show data or employee

Employee details are

Id Name Designation MobileNo MailId Department
{{employee.id}} {{employee.name}} {{employee.designation}} {{employee.mobileNo}} {{employee.mailId}} {{employee.department}}

Afterexecuting you will get following output.

Angular Spring boot Showing data in table
Fig: showing Employee data using spring boot and angular

Hope you understand how to use Angular and Spring boot to show data in HTML table..

Read More

Angularjs select : ng-repeat ng option default multiple select selected value

The post Angular Spring Boot showing data in table appeared first on Ebhor.com.

]]>
Angular14 Routing with example https://www.ebhor.com/angular-routing/ Fri, 27 Jan 2023 09:01:00 +0000 https://www.ebhor.com/?p=13695 What is Routing in Angular? Angular Router provides a way to navigate from one part to another part in a Single Page Application (SPA). How to create Routing in Angular? Here we used Angular 14 for this project. Would you like to add angular routing (y/n) At the time of the creation of the project, ... Read more

The post Angular14 Routing with example appeared first on Ebhor.com.

]]>
What is Routing in Angular?

Angular Router provides a way to navigate from one part to another part in a Single Page Application (SPA).

How to create Routing in Angular?

Here we used Angular 14 for this project.

Would you like to add angular routing (y/n)

At the time of the creation of the project, it will ask to include angular route press Y to add routing.

PS G:\angularproject> ng new test11
? Would you like to add Angular routing? (y/N) 
y

It will add angular routing to the angular project.

Creating Components for Routing

We will create the following components for Routing

  1. HomeComponent
  2. AboutUsComponent
  3. ContactUsComponent
  4. PricingComponent
  5. ProductsComponent
  6. TestimonialComponents

To generate the above components we used the following commands

> ng g c home
> ng g c aboutus
> ng  g c contactus
> ng  g c pricing
> ng  g c products
> ng  g c testimonial

Adding Routing Module

Open file app.module.ts and import AppRoutingModule.

Now your import statement will look like

imports: [
    BrowserModule,
    AppRoutingModule
  ],

This requires importing the following Module below

import { AppRoutingModule } from './app-routing.module';

Add routes to app-routing.module.ts

To create a routes route array takes objects of routes that have fields like path and component as below.

{ path: 'home', component: HomeComponent }

Add all components to route array.

const routes: Routes = [
  { path: 'home', component: HomeComponent },
  { path: 'aboutus', component: AboutusComponent },
  { path: 'contactus', component: ContactusComponent },
  { path: 'products', component: ProductsComponent },
  { path: 'pricing', component: PricingComponent },
  { path: 'testimonial', component: TestimonialComponent },
  { path: '',   redirectTo: '/home', pathMatch: 'full' }, // redirect to `first-component`
  { path: '**', component: HomeComponent },  // Wildcard route 
];

/home opens HomeComponent
/aboutus opens AboutusComponent
/countactus opens ContactusComponent

and similar for others.

In the last two path, one is ‘ ‘ (empty) and redirectTo is configured. It means if we do not provide any path it will redirect to /home.

So at the start when it will load localhost:4200 it will redirect to localhost:4200/home.

To configure the wildcard route here ** is used.

If any route is not configured then the default route works.

Here we specified HomeComponent as a wildcard.

create a constant routing component and add all components there.

export const routingComponents = [
  HomeComponent, AboutusComponent, ContactusComponent,
  ProductsComponent, PricingComponent, TestimonialComponent
]

Run and Access Routing

To run a project use ng serve command

it will open localhost:4200 and redirect to localhost:4200/home and shows the contents of HomeController.

Similar wat open localhost:4200/aboutus, locahost:4200/contactus etc.

It will show the default content of the respective controller.

index.html

  <base href=”/”> must be present at index.html

also to improve look and feel add bootstrap5.

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>AngularRouting</title>
  <base href="/">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="icon" type="image/x-icon" href="favicon.ico">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.2.0/css/bootstrap.min.css"
    integrity="sha512-XWTTruHZEYJsxV3W/lSXG1n3Q39YIWOstqvmFsdNEEQfHoZ6vm6E9GK2OrF6DSJSpIbRbi+Nn0WDPID9O7xB2Q=="
    crossorigin="anonymous" referrerpolicy="no-referrer" />
  <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
    integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM"
    crossorigin="anonymous"></script>
</head>
<body>
  <app-root></app-root>
</body>
</html>

Adding Menu at app.component.html

Bootstrap5 navbar is used to create menu

<nav class="navbar navbar-expand-lg navbar-light bg-light">
  <div class="container-fluid">
    <a class="navbar-brand" href="/home">Ebhor.com</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 ms-auto mb-2 mb-lg-0">
        <li class="nav-item">
          <a class="nav-link active" aria-current="page" href="/home">Home</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="/aboutus">About Us</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="/contactus">Contact Us</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="/pricing">Pricing</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="/products">Products</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="/testimonial">Testimonial</a>
        </li>
      </ul>
    </div>
  </div>
</nav>
<router-outlet></router-outlet>

<router-outlet></router-outlet> is required for angular routing.

Run and Check again

Fig: Angular Routing

Test all links.

All are working properly.

Adding Content to Components

1 home.component.html

<div class="container-fluid">
    <div id="carousel1">
        <div id="carouselExampleCaptions" class="carousel slide" data-bs-ride="false">
            <div class="carousel-indicators">
                <button type="button" data-bs-target="#carouselExampleCaptions" data-bs-slide-to="0" class="active" aria-current="true" aria-label="Slide 1"></button>
                <button type="button" data-bs-target="#carouselExampleCaptions" data-bs-slide-to="1" aria-label="Slide 2"></button>
                <button type="button" data-bs-target="#carouselExampleCaptions" data-bs-slide-to="2" aria-label="Slide 3"></button>
            </div>
            <div class="carousel-inner">
                <div class="carousel-item active">
                    <img src="https://source.unsplash.com/kWVImL5QxJI" class="d-block w-100" alt="..." style="height:600px">
                    <div class="carousel-caption d-none d-md-block">
                        <h5>First slide label</h5>
                        <p>Some representative placeholder content for the first slide.</p>
                    </div>
                </div>
                <div class="carousel-item">
                    <img src="https://source.unsplash.com/J4DnKxz_3sA" class="d-block w-100" alt="..." style="height:600px">
                    <div class="carousel-caption d-none d-md-block">
                        <h5>Second slide label</h5>
                        <p>Some representative placeholder content for the second slide.</p>
                    </div>
                </div>
                <div class="carousel-item">
                    <img src="https://source.unsplash.com/RzA6DUaiTl4" class="d-block w-100" alt="..." style="height:600px">
                    <div class="carousel-caption d-none d-md-block">
                        <h5>Third slide label</h5>
                        <p>Some representative placeholder content for the third slide.</p>
                    </div>
                </div>
            </div>
            <button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleCaptions" data-bs-slide="prev">
                <span class="carousel-control-prev-icon" aria-hidden="true"></span>
                <span class="visually-hidden">Previous</span>
            </button>
            <button class="carousel-control-next" type="button" data-bs-target="#carouselExampleCaptions" data-bs-slide="next">
                <span class="carousel-control-next-icon" aria-hidden="true"></span>
                <span class="visually-hidden">Next</span>
            </button>
        </div>
    </div>
    <div class="container">
    </div>
</div>

2 aboutus.component.html

<div class="container">
    <h1 class="text-center py-5">About Us</h1>
    <div class="py-4">
        <img src="https://source.unsplash.com/6awfTPLGaCE" class="img-fluid" style="width: 100%;height: 500px;" alt="...">
    </div>
    <p class="py-4">
        Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum
        sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies
        nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel,
        aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum
        felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate
        eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante,
        dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum.
        Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi. Nam eget dui. Etiam
        rhoncus. Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque
        sed ipsum. Nam quam nunc, blandit vel, luctus pulvinar, hendrerit id, lorem. Maecenas nec odio et ante tincidunt
        tempus. Donec vitae sapien ut libero venenatis faucibus. Nullam quis ante. Etiam sit amet orci eget eros
        faucibus tincidunt. Duis leo. Sed fringilla mauris sit amet nibh. Donec sodales sagittis magna. Sed consequat,
        leo eget bibendum sodales, augue velit cursus nunc,
    </p>
</div>

3 contactus.component.html

<div class="container">
    <h1 class="text-center py-5">Contact Us</h1>
    <div class="row py-3">
        <div class="col">
            <img src="https://source.unsplash.com/idhx-MOCDSk" class="img-fluid" alt="...">
        </div>
        <div class="col py-3">
            Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa.
            Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis,
            ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo,
            fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae,
            justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper
            nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim.
            Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius
            laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies
            nisi. Nam eget dui. Etiam rhoncus. Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero,
            sit amet adipiscing sem neque sed ipsum. Nam quam nunc, blandit vel, luctus pulvinar, hendrerit id, lorem.
            Maecenas nec odio et ante tincidunt tempus. Donec vitae sapien ut libero venenatis faucibus. Nullam quis
            ante. Etiam sit amet orci eget eros faucibus tincidunt. Duis leo. Sed fringilla mauris sit amet nibh. Donec
            sodales sagittis magna. Sed consequat, leo eget bibendum sodales, augue velit cursus nunc,
        </div>
    </div>

    <div class="row ">
        <h2 div="" class="text-center">Submit Your Query</h2>
        <div class="col-4"></div>
        <div class="col-8">
            <div class="py-3">
                <label for="exampleFormControlInput1" class="form-label">Email address</label>
                <input type="email" class="form-control" id="exampleFormControlInput1" placeholder="[email protected]">
            </div>
            <div class="py-3">
                <label for="exampleFormControlTextarea1" class="form-label">Query</label>
                <textarea class="form-control" id="exampleFormControlTextarea1" rows="3"></textarea>
            </div>
            <div class="d-grid gap-2">
                <button class="btn btn-primary" type="button">Submit</button>
            </div>
        </div>
    </div>
</div>

4 pricing.component.html

<div class="container">
    <h1 class="text-center py-5">Pricing</h1>
    <div class="lead text-muted py-2">
        We are know brand we have 23m regular visitor customer
        We provide items at very low price
    </div>
    <div class="row py-2">
        <div class="row">
            <div class="row">
                <div class="col">
                    <div class="card mb-4 rounded-3 shadow-sm">
                        <div class="card-header py-3">
                            <h4 class="my-0 fw-normal">Free</h4>
                        </div>
                        <div class="card-body">
                            <h1 class="card-title pricing-card-title">$0<small class="text-muted fw-light">/mo</small>
                            </h1>
                            <ul class="list-unstyled mt-3 mb-4">
                                <li>Feature1</li>
                                <li>Feature2</li>
                                <li>Feature3</li>
                                <li>Feature4</li>
                                <li>Feature5</li>
                            </ul>
                            <button type="button" class="w-100 btn btn-lg btn-outline-primary">Sign up for free</button>
                        </div>
                    </div>
                </div>
                <div class="col">
                    <div class="card mb-4 rounded-3 shadow-sm ">
                        <div class="card-header py-3 bg-secondary text-white">
                            <h4 class="my-0 fw-normal">Standard</h4>
                        </div>
                        <div class="card-body">
                            <h1 class="card-title pricing-card-title">$10<small class="text-muted fw-light">/mo</small>
                            </h1>
                            <ul class="list-unstyled mt-3 mb-4">
                                <li>Feature1</li>
                                <li>Feature2</li>
                                <li>Feature3</li>
                                <li>Feature4</li>
                                <li>Feature5</li>
                            </ul>
                            <button type="button" class="w-100 btn btn-lg btn-outline-primary">Sign up for free</button>
                        </div>
                    </div>
                </div>
                <div class="col">
                    <div class="card mb-4 rounded-3 shadow-sm border-primary">
                        <div class="card-header py-3 bg-primary text-white">
                            <h4 class="my-0 fw-normal">Premium</h4>
                        </div>
                        <div class="card-body">
                            <h1 class="card-title pricing-card-title">$40<small class="text-muted fw-light">/mo</small>
                            </h1>
                            <ul class="list-unstyled mt-3 mb-4">
                                <li>Feature1</li>
                                <li>Feature2</li>
                                <li>Feature3</li>
                                <li>Feature4</li>
                                <li>Feature5</li>
                            </ul>
                            <button type="button" class="w-100 btn btn-lg btn-primary">Sign up for free</button>
                        </div>
                    </div>
                </div>
                <div class="col">
                    <div class="card mb-4 rounded-3 shadow-sm">
                        <div class="card-header py-3 bg-warning text-dark">
                            <h4 class="my-0 fw-normal">Platinum</h4>
                        </div>
                        <div class="card-body">
                            <h1 class="card-title pricing-card-title">$100<small class="text-muted fw-light">/mo</small>
                            </h1>
                            <ul class="list-unstyled mt-3 mb-4">
                                <li>Feature1</li>
                                <li>Feature2</li>
                                <li>Feature3</li>
                                <li>Feature4</li>
                                <li>Feature5</li>
                            </ul>
                            <button type="button" class="w-100 btn btn-lg btn-outline-primary">Sign up for free</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

5 products.component.html

<div class="container">
    <h1 class="text-center py-5">Products</h1>
    <div class="row py-4">
        <div class="col">
            <div class="card" style="width: 18rem;">
                <img src="https://source.unsplash.com/LxVxPA1LOVM" class="card-img-top" style="height: 220px" alt="...">
                <div class="card-body">
                    <h5 class="card-title">Product</h5>
                    <p class="card-text">Product description very good Products</p>
                    <span class=""> <i class="bi bi-currency-rupee"></i> 4500.00</span>
                    <a href="#" class="card-link">Buy Now</a>
                </div>
            </div>
        </div>
        <div class="col">
            <div class="card" style="width: 18rem;">
                <img src="https://source.unsplash.com/1SAnrIxw5OY" class="card-img-top" style="height: 220px" alt="...">
                <div class="card-body">
                    <h5 class="card-title">Product</h5>
                    <p class="card-text">Product description very good Products</p>
                    <span class=""> <i class="bi bi-currency-rupee"></i> 57000.00</span>
                    <a href="#" class="card-link">Buy Now</a>
                </div>
            </div>
        </div>
        <div class="col">
            <div class="card" style="width: 18rem;">
                <img src="https://source.unsplash.com/oCXVxwTFwqE" class="card-img-top" style="height: 220px" alt="...">
                <div class="card-body">
                    <h5 class="card-title">Product</h5>
                    <p class="card-text">Product description very good Products</p>
                    <span class=""> <i class="bi bi-currency-rupee"></i> 3300.00</span>
                    <a href="#" class="card-link">Buy Now</a>
                </div>
            </div>
        </div>
        <div class="col">
            <div class="card" style="width: 18rem;">
                <img src="https://source.unsplash.com/RU0KVBUqBLk" class="card-img-top" style="height: 220px" alt="...">
                <div class="card-body">
                    <h5 class="card-title">Product</h5>
                    <p class="card-text">Product description very good Products</p>
                    <span class=""> <i class="bi bi-currency-rupee"></i> 61000.00</span>
                    <a href="#" class="card-link">Buy Now</a>
                </div>
            </div>
        </div>
    </div>
    <div class="row py-4">
        <div class="col">
            <div class="card" style="width: 18rem;">
                <img src="https://source.unsplash.com/LxVxPA1LOVM" class="card-img-top" style="height: 220px" alt="...">
                <div class="card-body">
                    <h5 class="card-title">Product</h5>
                    <p class="card-text">Product description very good Products</p>
                    <span class=""> <i class="bi bi-currency-rupee"></i> 4500.00</span>
                    <a href="#" class="card-link">Buy Now</a>
                </div>
            </div>
        </div>
        <div class="col">
            <div class="card" style="width: 18rem;">
                <img src="https://source.unsplash.com/1SAnrIxw5OY" class="card-img-top" style="height: 220px" alt="...">
                <div class="card-body">
                    <h5 class="card-title">Product</h5>
                    <p class="card-text">Product description very good Products</p>
                    <span class=""> <i class="bi bi-currency-rupee"></i> 57000.00</span>
                    <a href="#" class="card-link">Buy Now</a>
                </div>
            </div>
        </div>
        <div class="col">
            <div class="card" style="width: 18rem;">
                <img src="https://source.unsplash.com/oCXVxwTFwqE" class="card-img-top" style="height: 220px" alt="...">
                <div class="card-body">
                    <h5 class="card-title">Product</h5>
                    <p class="card-text">Product description very good Products</p>
                    <span class=""> <i class="bi bi-currency-rupee"></i> 3300.00</span>
                    <a href="#" class="card-link">Buy Now</a>
                </div>
            </div>
        </div>
        <div class="col">
            <div class="card" style="width: 18rem;">
                <img src="https://source.unsplash.com/RU0KVBUqBLk" class="card-img-top" style="height: 220px" alt="...">
                <div class="card-body">
                    <h5 class="card-title">Product</h5>
                    <p class="card-text">Product description very good Products</p>
                    <span class=""> <i class="bi bi-currency-rupee"></i> 61000.00</span>
                    <a href="#" class="card-link">Buy Now</a>
                </div>
            </div>
        </div>
    </div>
    <div class="row py-4">
        <div class="col">
            <div class="card" style="width: 18rem;">
                <img src="https://source.unsplash.com/LxVxPA1LOVM" class="card-img-top" style="height: 220px" alt="...">
                <div class="card-body">
                    <h5 class="card-title">Product</h5>
                    <p class="card-text">Product description very good Products</p>
                    <span class=""> <i class="bi bi-currency-rupee"></i> 4500.00</span>
                    <a href="#" class="card-link">Buy Now</a>
                </div>
            </div>
        </div>
        <div class="col">
            <div class="card" style="width: 18rem;">
                <img src="https://source.unsplash.com/1SAnrIxw5OY" class="card-img-top" style="height: 220px" alt="...">
                <div class="card-body">
                    <h5 class="card-title">Product</h5>
                    <p class="card-text">Product description very good Products</p>
                    <span class=""> <i class="bi bi-currency-rupee"></i> 57000.00</span>
                    <a href="#" class="card-link">Buy Now</a>
                </div>
            </div>
        </div>
        <div class="col">
            <div class="card" style="width: 18rem;">
                <img src="https://source.unsplash.com/oCXVxwTFwqE" class="card-img-top" style="height: 220px" alt="...">
                <div class="card-body">
                    <h5 class="card-title">Product</h5>
                    <p class="card-text">Product description very good Products</p>
                    <span class=""> <i class="bi bi-currency-rupee"></i> 3300.00</span>
                    <a href="#" class="card-link">Buy Now</a>
                </div>
            </div>
        </div>
        <div class="col">
            <div class="card" style="width: 18rem;">
                <img src="https://source.unsplash.com/RU0KVBUqBLk" class="card-img-top" style="height: 220px" alt="...">
                <div class="card-body">
                    <h5 class="card-title">Product</h5>
                    <p class="card-text">Product description very good Products</p>
                    <span class=""> <i class="bi bi-currency-rupee"></i> 61000.00</span>
                    <a href="#" class="card-link">Buy Now</a>
                </div>
            </div>
        </div>
    </div>
    <div class="row py-4">
        <div class="col">
            <div class="card" style="width: 18rem;">
                <img src="https://source.unsplash.com/LxVxPA1LOVM" class="card-img-top" style="height: 220px" alt="...">
                <div class="card-body">
                    <h5 class="card-title">Product</h5>
                    <p class="card-text">Product description very good Products</p>
                    <span class=""> <i class="bi bi-currency-rupee"></i> 4500.00</span>
                    <a href="#" class="card-link">Buy Now</a>
                </div>
            </div>
        </div>
        <div class="col">
            <div class="card" style="width: 18rem;">
                <img src="https://source.unsplash.com/1SAnrIxw5OY" class="card-img-top" style="height: 220px" alt="...">
                <div class="card-body">
                    <h5 class="card-title">Product</h5>
                    <p class="card-text">Product description very good Products</p>
                    <span class=""> <i class="bi bi-currency-rupee"></i> 57000.00</span>
                    <a href="#" class="card-link">Buy Now</a>
                </div>
            </div>
        </div>
        <div class="col">
            <div class="card" style="width: 18rem;">
                <img src="https://source.unsplash.com/oCXVxwTFwqE" class="card-img-top" style="height: 220px" alt="...">
                <div class="card-body">
                    <h5 class="card-title">Product</h5>
                    <p class="card-text">Product description very good Products</p>
                    <span class=""> <i class="bi bi-currency-rupee"></i> 3300.00</span>
                    <a href="#" class="card-link">Buy Now</a>
                </div>
            </div>
        </div>
        <div class="col">
            <div class="card" style="width: 18rem;">
                <img src="https://source.unsplash.com/RU0KVBUqBLk" class="card-img-top" style="height: 220px" alt="...">
                <div class="card-body">
                    <h5 class="card-title">Product</h5>
                    <p class="card-text">Product description very good Products</p>
                    <span class=""> <i class="bi bi-currency-rupee"></i> 61000.00</span>
                    <a href="#" class="card-link">Buy Now</a>
                </div>
            </div>
        </div>
    </div>
    <div class="row py-4">
        <div class="col">
            <div class="card" style="width: 18rem;">
                <img src="https://source.unsplash.com/LxVxPA1LOVM" class="card-img-top" style="height: 220px" alt="...">
                <div class="card-body">
                    <h5 class="card-title">Product</h5>
                    <p class="card-text">Product description very good Products</p>
                    <span class=""> <i class="bi bi-currency-rupee"></i> 4500.00</span>
                    <a href="#" class="card-link">Buy Now</a>
                </div>
            </div>
        </div>
        <div class="col">
            <div class="card" style="width: 18rem;">
                <img src="https://source.unsplash.com/1SAnrIxw5OY" class="card-img-top" style="height: 220px" alt="...">
                <div class="card-body">
                    <h5 class="card-title">Product</h5>
                    <p class="card-text">Product description very good Products</p>
                    <span class=""> <i class="bi bi-currency-rupee"></i> 57000.00</span>
                    <a href="#" class="card-link">Buy Now</a>
                </div>
            </div>
        </div>
        <div class="col">
            <div class="card" style="width: 18rem;">
                <img src="https://source.unsplash.com/oCXVxwTFwqE" class="card-img-top" style="height: 220px" alt="...">
                <div class="card-body">
                    <h5 class="card-title">Product</h5>
                    <p class="card-text">Product description very good Products</p>
                    <span class=""> <i class="bi bi-currency-rupee"></i> 3300.00</span>
                    <a href="#" class="card-link">Buy Now</a>
                </div>
            </div>
        </div>
        <div class="col">
            <div class="card" style="width: 18rem;">
                <img src="https://source.unsplash.com/RU0KVBUqBLk" class="card-img-top" style="height: 220px" alt="...">
                <div class="card-body">
                    <h5 class="card-title">Product</h5>
                    <p class="card-text">Product description very good Products</p>
                    <span class=""> <i class="bi bi-currency-rupee"></i> 61000.00</span>
                    <a href="#" class="card-link">Buy Now</a>
                </div>
            </div>
        </div>
    </div>
    <div class="row py-4">
        <div class="col">
            <div class="card" style="width: 18rem;">
                <img src="https://source.unsplash.com/LxVxPA1LOVM" class="card-img-top" style="height: 220px" alt="...">
                <div class="card-body">
                    <h5 class="card-title">Product</h5>
                    <p class="card-text">Product description very good Products</p>
                    <span class=""> <i class="bi bi-currency-rupee"></i> 4500.00</span>
                    <a href="#" class="card-link">Buy Now</a>
                </div>
            </div>
        </div>
        <div class="col">
            <div class="card" style="width: 18rem;">
                <img src="https://source.unsplash.com/1SAnrIxw5OY" class="card-img-top" style="height: 220px" alt="...">
                <div class="card-body">
                    <h5 class="card-title">Product</h5>
                    <p class="card-text">Product description very good Products</p>
                    <span class=""> <i class="bi bi-currency-rupee"></i> 57000.00</span>
                    <a href="#" class="card-link">Buy Now</a>
                </div>
            </div>
        </div>
        <div class="col">
            <div class="card" style="width: 18rem;">
                <img src="https://source.unsplash.com/oCXVxwTFwqE" class="card-img-top" style="height: 220px" alt="...">
                <div class="card-body">
                    <h5 class="card-title">Product</h5>
                    <p class="card-text">Product description very good Products</p>
                    <span class=""> <i class="bi bi-currency-rupee"></i> 3300.00</span>
                    <a href="#" class="card-link">Buy Now</a>
                </div>
            </div>
        </div>
        <div class="col">
            <div class="card" style="width: 18rem;">
                <img src="https://source.unsplash.com/RU0KVBUqBLk" class="card-img-top" style="height: 220px" alt="...">
                <div class="card-body">
                    <h5 class="card-title">Product</h5>
                    <p class="card-text">Product description very good Products</p>
                    <span class=""> <i class="bi bi-currency-rupee"></i> 61000.00</span>
                    <a href="#" class="card-link">Buy Now</a>
                </div>
            </div>
        </div>
    </div>
</div>

6 testimonial.component.html

<div class="container">
    <h1 class="text-center py-5">Testimonial</h1>
    <div class="row py-4">
        <div class="col">
            <div class="card mb-3" style="max-width: 540px;">
                <div class="row g-0">
                    <div class="col-md-4">
                        <img src="https://source.unsplash.com/6awfTPLGaCE" class="img-fluid rounded-start" alt="...">
                    </div>
                    <div class="col-md-8">
                        <div class="card-body">
                            <h5 class="card-title">Mr. Ram</h5>
                            <p class="card-text">I have a very good experiance with this site. I am regular user of this
                                site</p>
                            <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="col">
            <div class="card mb-3" style="max-width: 540px;">
                <div class="row g-0">
                    <div class="col-md-4">
                        <img src="https://source.unsplash.com/6awfTPLGaCE" class="img-fluid rounded-start" alt="...">
                    </div>
                    <div class="col-md-8">
                        <div class="card-body">
                            <h5 class="card-title">Mr. Arnold</h5>
                            <p class="card-text">I have a very good experiance with this site. I am regular user of this
                                site</p>
                            <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="row py-4">
        <div class="col">
            <div class="card mb-3" style="max-width: 540px;">
                <div class="row g-0">
                    <div class="col-md-4">
                        <img src="https://source.unsplash.com/6awfTPLGaCE" class="img-fluid rounded-start" alt="...">
                    </div>
                    <div class="col-md-8">
                        <div class="card-body">
                            <h5 class="card-title">Mr. Ram</h5>
                            <p class="card-text">I have a very good experiance with this site. I am regular user of this
                                site</p>
                            <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="col">
            <div class="card mb-3" style="max-width: 540px;">
                <div class="row g-0">
                    <div class="col-md-4">
                        <img src="https://source.unsplash.com/6awfTPLGaCE" class="img-fluid rounded-start" alt="...">
                    </div>
                    <div class="col-md-8">
                        <div class="card-body">
                            <h5 class="card-title">Mr. Arnold</h5>
                            <p class="card-text">I have a very good experiance with this site. I am regular user of this
                                site</p>
                            <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

Run again the project.

You will see following output.

Output

Home Page

Angular Routing Home page
Fig: Home page

About Us Page

Angular Routing About Us
Fig: About us

Contact us Page

Angular Routing Contactus page
Fig: Contact us

Products Page

Angular Routing Product page
Fig: products

Pricing Page

Angular Routing Pricing page
Fig: Pricing

Testimonial Page

Angular Routing Testimonial page
Fig Testimonial

Read More

How to create First Angular App (Step by step )

Angular Spring Boot showing data in table

Reference

Common Routing Tasks

The post Angular14 Routing with example appeared first on Ebhor.com.

]]>
How to create First Angular App (Step by step ) https://www.ebhor.com/how-to-create-first-angular-app/ Fri, 27 Jan 2023 08:11:00 +0000 https://www.ebhor.com/?p=13665 We are using visual studio 1.69 code editor for this project.To use Angular your computer should have node.js and angular installed.To install node see this and to install angular see this To check the version of node.js use the node -v commandand to check the angular version use the ng version commandhere we are usingAngular ... Read more

The post How to create First Angular App (Step by step ) appeared first on Ebhor.com.

]]>
We are using visual studio 1.69 code editor for this project.
To use Angular your computer should have node.js and angular installed.
To install node see this and to install angular see this

To check the version of node.js use the node -v command
and to check the angular version use the ng version command
here we are using
Angular CLI: 14.1.0
Node: 16.15.0
Package Manager: npm 8.5.5
OS: win32 x64

Creating Folder

We have created a folder angular project in G:\ drive
we will save all our angular projects there.
On the Visual Studio code editor menu click on Terminal then new terminal (CTRL+SHIFT+).
It will open a new terminal
then first move to G:\angularproject
C:> cd G:
PS G:> cd .\angularproject\

How to create First angular app

To create a new Angular project use
ng new First-app
here ng new is the command and First-app is the name of the project.
It will ask a few questions

Would you like to add Angular routing?
select No
Which stylesheet format would you like to use? CSS
Enter

This will generate all files and components of angular.

PS G:\angularproject&gt; ng new First-app
? Would you like to add Angular routing? No
? Which stylesheet format would you like to use? CSS
CREATE First-app/angular.json (2937 bytes)
CREATE First-app/package.json (1040 bytes)
CREATE First-app/README.md (1062 bytes)
CREATE First-app/tsconfig.json (863 bytes)
CREATE First-app/.editorconfig (274 bytes)
CREATE First-app/.gitignore (548 bytes)
CREATE First-app/.browserslistrc (600 bytes)
CREATE First-app/karma.conf.js (1426 bytes)
CREATE First-app/tsconfig.app.json (287 bytes)
CREATE First-app/tsconfig.spec.json (333 bytes)
CREATE First-app/.vscode/extensions.json (130 bytes)
CREATE First-app/.vscode/launch.json (474 bytes)
CREATE First-app/.vscode/tasks.json (938 bytes)
CREATE First-app/src/favicon.ico (948 bytes)
CREATE First-app/src/index.html (294 bytes)
CREATE First-app/src/main.ts (372 bytes)
CREATE First-app/src/polyfills.ts (2338 bytes)
CREATE First-app/src/styles.css (80 bytes)
CREATE First-app/src/test.ts (749 bytes)
CREATE First-app/src/assets/.gitkeep (0 bytes)
CREATE First-app/src/environments/environment.prod.ts (51 bytes)
CREATE First-app/src/environments/environment.ts (658 bytes)
CREATE First-app/src/app/app.module.ts (314 bytes)
CREATE First-app/src/app/app.component.html (23083 bytes)
CREATE First-app/src/app/app.component.spec.ts (965 bytes)
CREATE First-app/src/app/app.component.ts (213 bytes)
CREATE First-app/src/app/app.component.css (0 bytes)

To run this project type
ng serve
this will run the project on localhost:4200/
open the URL in the browser.
You will see the following output

How to run a first angular app
Fig: How to run a first angular app

Adding Your own Content

To change the above content goto

src->app->app.component.html

remove all content.

then put <h2>{{title}}</h2>

Then check the browser.

First Angular App
Fig: First Angular App

Adding More Content

It will show the Title name of your project.

Adding data to app.component.html

To add static content we can directly write in app.component.html

To add dynamic content you have to add content in app.component.ts

We added title description and author in class AppComponent as below

import { Component } from '@angular/core';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  title = 'My First App';
  description="This is my first app in angular";
  author="Manish";
}

in app.component.html

<h2>{{title}}</h2>
<p>{{description}}</p>
<p>created by<strong> {{author}}</strong></p>

To access app.component.html we use interpolation.

It will produce the following output

First Angular App Edited
Fig: First Angular App Edited

Read More

Angular Spring Boot showing data in table

Angular14 Routing with example

The post How to create First Angular App (Step by step ) appeared first on Ebhor.com.

]]>