- Tableau
- http://archive.ics.uci.edu/ml/index.php
Month: November 2017
Angular 4 http post with php
Component or Service:
let data = {'title': 'foo', 'body': 'bar', 'userId': 1};
this.http.post('http://localhost/angular4/angcrud/add_student_action.php', data)
.subscribe(
(res:Response) => {
console.log(res.json());
},
err => {
console.log("Error occured");
}
);
Php Script:
<?php
$postdata = file_get_contents("php://input");
$request = json_decode($postdata);
header('Content-type: application/json');
header("Access-Control-Allow-Origin: *");
header('Access-Control-Allow-Headers: X-Requested-With, content-type, access-control-allow-origin, access-control-allow-methods, access-control-allow-headers');
//$res_ar = array("foo"=> $_REQUEST['body']);
echo json_encode($request);
?>
<form #studentForm = "ngForm" (ngSubmit)="addStudentRecord(studentForm.value)"> First name:<br> <input type="text" name="firstname" value="Mickey" ngModel> <br> Last name:<br> <input type="text" name="lastname" value="Mouse" ngModel> <br><br> <input type="submit" value="Submit"> </form>
Angular 4 JSON CRUD
- install json server on windows
npm install -g json-server - run json server
json-server -p 5555 products.json - https://www.youtube.com/watch?v=HCHvrbAd1QA
- https://www.youtube.com/watch?v=WVlNj_6_-uA
- https://www.youtube.com/watch?v=6T1TF7lgVSA
- Angular 4 POST
- Angular 4 Receive data in Php