Wie würde man Daten aus einer MySql-Datenbank mit PHP-Code in einer Angular2-Anwendung löschen? Die nächste Beratung ist für Angular 1 und ist wie folgt:Löschen von Daten in Angular2 App in PHP
$scope.deleteProduct = function(id){
// ask the user if he is sure to delete the record
if(confirm("Are you sure?")){
// post the id of product to be deleted
$http.post('delete_product.php', {
'id' : id
}).success(function (data, status, headers, config){
// tell the user product was deleted
Materialize.toast(data, 4000);
// refresh the list
$scope.getAll();
});
}
}
Ist es möglich, die post
Methode zu verwenden, ähnlich:
import { Injectable } from '@angular/core';
import { Http, Response, Headers } from '@angular/http';
import 'rxjs/Rx';
@Injectable()
export class HttpService {
constructor(private http: Http) {}
deleteData() {
return this.http.post('delete_record.php')
}
}
Einsicht/Erfahrung mit Angular2/PHP geschätzt würde.