<h1>Select record to edit </h1>{{msg}}{{phone_number}}</br></br>
<form>
<table>
<tr>
<td>First Name: </td><td><input type="text" ng-model="firstname">
</td>
</tr>
<tr>
<td>Second Name: </td><td><input type="text" ng-model="secondname">
</td>
</tr>
<tr>
<td>Email: </td><td><input type="email" ng-model="email"></td>
</tr>
<tr>
<td>Status: </td>
<td><input type="radio" value="active" ng-model =
"status">Active</td>
<td><input type="radio" value="inactive" ng-
model="status">Inactive</td>
</tr>
<tr>
<td><input type="button" value="Submit" ng-click="updateData()" />
</tr> {{error}}
</form>
<div ng-init="displayContacts()">
<table border="1px">
<thead>
<tr>
<th>First Name</th>
<th>Second Name</th>
<th>Email</th>
<th>Phone Number</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="contact in data">
<td>{{contact.first_name}}</td>
<td>{{contact.second_name}}</td>
<td>{{contact.email}}</td>
<td>{{contact.phone_number}}</td>
<td>{{contact.status}}</td>
<td><button ng-
click="editContacts(contact.phone_number);">Edit</button></td>
</tr>
</tbody>
</table>
app.controller('EditController', function($scope, $http, ) {
$scope.message = 'Hello from EditController';
$scope.updateContacts = function(){
$http.post("update.php", {
'first_name':$scope.firstname,
'second_name' : $scope.secondname,
'email' : $scope.email,
'status' : $scope.status}).success(function(msg){
$scope.msg = "Data updated";
}).error(function(error){
$scope.error(error);
})
}
$scope.displayContacts = function(){
$http.get("retrieveAll.php").
success(function(data){
$scope.data = data;
})
}
$scope.editContacts = function(phone_number){
$scope.phone_number = phone_number
//var phone= phone_number;
$scope.msg = "Edit for number :";
}
参数phone_number正在使用editContact(contact.phone_number)函数从editContact.html传递。我想现在发送到函数updateContact,在那里我使用phone_number进行php调用以更新与该特定phone_number的联系。
我看了服务但不知道我怎么能申请这种情况,如果有人可以给我看代码或者可以建议,我将不胜感激