0
<script type="text/javascript">
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope, $http) {
$scope.Register = function() {
$http.post("http-post.json",{'id': $scope.id,'name': $scope.name,'email': $scope.email,'phone': $scope.phone})
.success(function(response) {
$scope.usersData = response.users;
});
};
});
</script>
> {
"users": [
{
"id":"1",
"name": "Alfreds Futterkis",
"email": "[email protected]",
"phone": "1478523691"
},
{
"id":"2",
"name": "Blauer See",
"email": "[email protected]",
"phone": "7896541230"
},
{
"id":"3",
"name": "Blondel pèreet",
"email": "[email protected]",
"phone": "2589631470"
},
{
"id":"4",
"name": "Bottom-Dollar",
"email": "[email protected]",
"phone": "3698521470"
},
{
"id":"5",
"name": "Comércio Mineiro",
"email": "São [email protected]",
"phone": "1478523690"
}
]
}
我的JSON文件名是http-post.json – mosin