“Angular http” Code-Antworten

Angular http

	constructor(private http: HttpClient) { }

	//GET ALL
	GetAll(): Observable<any> {
		return this.http.get(this.baseUrl + "/all");
	}
    
    //GET SINGLE
    GetSingle(id: any): Observable<any> {
		return this.http.get(this.baseUrl + "/single/" + id);
	}
    
    //PUT
    Update(obj: Object) {
		const data = JSON.stringify(obj);
		return this.http.put(this.baseUrl, data, {
			headers: new HttpHeaders({
				"Content-Type": "application/json",
			}),
		});
	}

    //POST
	Create(obj: Object) {
		const data = JSON.stringify(obj);
		return this.http.post(this.baseUrl, data, {
			headers: new HttpHeaders({
				"Content-Type": "application/json",
			}),
		});
	}
    //DELETE
	Delete(obj: Object) {
		const data = JSON.stringify(obj);
		return this.http.delete(this.baseUrl + "/delete", data, {
			headers: new HttpHeaders({
				"Content-Type": "application/json",
			}),
		});
	}
Lucky Lark

http in AngularJs bekommen

var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope, $http) {
  $http.get("welcome.htm")
  .then(function(response) {
    $scope.myWelcome = response.data;
  });
});
Harendra

Ähnliche Antworten wie “Angular http”

Fragen ähnlich wie “Angular http”

Weitere verwandte Antworten zu “Angular http” auf TypeScript

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen