Web Service Implementation in Angular Framework for Add,Edit and Delete Record

0
1.1) First BackEnd Developer Create Web Services using PHP,.NET, JAVA , PYTHON, RUBY or CI.

      BackEnd Developers will provide Web URL, Input Parameters and Output Parameter and Method (GET, POST)

for example http://shivaconceptsolution.com/webservices/tr.php

Input Parameters:-  tno,tdet

Post Method


You can use postman or other web services checking tools

for postman open chrome and write chrome://apps in url , download plugin, and check URL after successful login.



1.2 create component then create a path


1.3 write the following code to call web service under component typescript

import { Component, OnInit } from '@angular/core';
import { HttpClient,HttpHeaders } from '@angular/common/http';
const httpOptions = {
  headers: new HttpHeaders({
    'Content-Type':  'application/json'
  })
};
@Component({
  selector: 'app-truck',
  templateUrl: './truck.component.html',
  styleUrls: ['./truck.component.css']
})

export class TruckComponent implements OnInit {
  data:string='';
  tid:string='';
  tdesc:string='';
   constructor(private http: HttpClient) { }

  ngOnInit() {
  this.addTruck ();
  }

  addTruck () {

   let t = {'tno':'Mytruck','tdet':'nilesj'};
  this.http.post("https://shivaconceptsolution.com/webservices/tr.php",t,httpOptions).subscribe((res)=>{
            console.log(res);
         
        });
        alert('data inserted');
}
}




Post a Comment

0Comments

POST Answer of Questions and ASK to Doubt

Post a Comment (0)