Envoyer l'ID de la requête HTTP
Bonjour,
Je dois envoyer l'ID d'un client vers la page modify.html à partir de la page clients.html quand je clique sur le lien Modify. Voilà ce que j'ai fait :
clients.html :
Code:
1 2 3 4 5 6 7 8
|
<tbody>
<tr ng-repeat="post in posts>
<td align="center">{{post.id}}</td>
<td align="center">{{post.nom}}</td>
<td align="center"><a ui-sref="app.modifier({customerID:post.id})">Modify</a></td>
</tr>
</tbody> |
Modify.html :
Code:
1 2 3 4 5 6 7
|
<div class="form-group">
<label class="col-sm-1 control-label">Nom:</label>
<div class="col-sm-1">
<input type="text" class="form-control rounded" ng-model="usernom">
</div>
</div> |
Et le controller :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| .controller('editController', ['$scope', '$http' ,function($scope,$http) {
$scope.errors = [];
$scope.msgs = [];
$scope.usershow = function() {
$scope.errors.splice(0, $scope.errors.length); // remove all error messages
$scope.msgs.splice(0, $scope.msgs.length);
$http({method: 'GET', url: 'MyURL?id='+$scope.userid+'&nom=test}).success(function(data, status, headers, config){
if (data.msg != '')
{
$scope.msgs.push(data.msg);
}
else
{
$scope.errors.push(data.error);
}
}).error(function(data, status) {
$scope.errors.push(status);
});}}]) |
router.js:
Code:
1 2 3 4 5
| .state('app.modifier', {
url: 'client/modifier/:customerID',
templateUrl: 'tpl/modify.html',
controller: 'editController'
}) |
Je peux obtenir l'ID sélectionnée de la table dans l'URL du navigateur mais je ne peux pas l'envoyer à la requête HTTP.
Merci pour l'aide.