Angular 6 applications – Insert, Fetch , Edit – update , Delete Operations
Today, We want to share with you Angular 6 applications – Insert, Fetch , Edit – update , Delete Operations.
In this post we will show you Angular 6 Insert Update delete Example, hear for Angular 6 PHP CRUD (Create, Read, Update, Delete) Operations we will give you demo and example for implement.
In this post, we will learn about Insert, Update, Delete Data in MySQL using Angular 6 with PHP with an example.
Angular 6 Example
Angular Latest My Previous Post With Source code Read more…..
- Angular 6 Folder Project Structure
- Angular 6 CLI Installation
- Angular 6 Module File
- Angular 6 Components
- Angular 6 Services
- Angular 6 Routing
- Angular 6 CSS
- Angular 6 Class Binding
- Angular 6 Animation
- Angular 6 Templating
- Angular 6 HTTP Client
Angular 6 CRUD Example – Part 2
Step 4: Make a JSON server that serves the simple data.
i should the fake dummy data to work with that is why I have to use one package called as a json-server for this Example. With it, I can make a fake server side called REST api.
npm install -g json-server
make one file called Student.json . so us add the following some data inside like as a Student.json file.
// Student.json { "students": [{ "id": 1, "name": "ND", "country": "Mumbai", "gender":"Male", "department":"Google adsense" }, { "id": 2, "name": "krulana", "country": "gova", "gender":"FEMale", "department":"Youtube" },{ "id": 3, "name": "jaydeeo", "country": "rajkot", "gender":"Male", "department":"SEO" }] }
And then, first of all the start the pure JSON server using the following some command.
json-server --watch Student.json
Step 5: Setup HttpClient for service.
Angular 6 is full best Frontend Framework custom javascripts, therefor it has depenedet HTTP module. therefor first let us configure inside Like as app.module.ts file.
// app.module.ts import { HttpClientModule } from '@angular/common/http'; imports: [ BrowserModule, RouterModule.forRoot(routes), HttpClientModule, ],
And then, make models folder inn this file and inside models folder, make one file called like as a student.model.ts.
// student.model.ts export class Student { id: number; name: string; country: string; gender: string; department: string; }
// student.service.ts
import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; @Injectable() export class StudentService { LIVE_URI = 'http://localhost:3000'; constructor(private httpClient: HttpClient) { } getStudents() { return this.httpClient.get(`${this.LIVE_URI}/students`); } }
And then, import student.service.ts service file data and student.model.ts model file inside this file list-students.component.ts file.
// list-students.component.ts import { Component, OnInit } from '@angular/core'; import { Student } from '../models/student.model'; // Import StudentService import { StudentService } from './student.service'; @Component({ selector: 'app-list-students', templateUrl: './list-students.component.html', styleUrls: ['./list-students.component.css'] }) export class ListStudentsComponent implements OnInit { students: Student[]; constructor(private _studentService: StudentService) { } ngOnInit() { this.getStudents(); } public getStudents() { this._studentService.getStudents().subscribe((data: Student[]) => { this.students = data; }); } }
js Loop through that simple data and view it as a DOM HTML table inside list-students.component.html file.
<table class="table table-bordered"> <thead> <tr> <th>stud Id</th> <th>stud Name</th> <th>stud City</th> <th>stud Gender</th> <th>stud Department</th> </tr> </thead> <tbody> <tr> <td>{{student.id}}</td> <td>{{student.name}}</td> <td>{{student.country}}</td> <td>{{student.gender}}</td> <td>{{student.department}}</td> </tr> </tbody> </table>
More Details of the Angular 6 Angular 6 Introduction Tutorial features of angular 6.0
Angular 6 Examples
There are the Angular 6 Step By Step Example and Learning AngularJS
- Angular 6 applications β Insert, Fetch , Edit β update , Delete Operations
- Angular 6 CRUD
- Angular 6 and ASP.NET Core 2.0 Web API
- Angular 6 features
- Angular 6 Form Validation
- Angular 6 β User Registration and Login
- Angularjs 6 User Registration and Login Authentication
- Angular 6 CLI Installation Tutorial With Example
- Angular 6 Toast Message Notifications From Scratch
We hope you get an idea about Angular 6 CRUD Example
We would like to have feedback on my Information blog .
Your valuable any feedback, Good question, Inspirational Quotes, or Motivational comments about this article are always welcome.
If you liked this post, Please donβt forget to share this as Well as Like FaceBook Page.
We hope This Post can help you…….Good Luck!.