0
在以下代碼中,我需要將票證ID作爲方法參數。 NG點擊= 「rejectTicket({{ticket.id}})」(ofcourse這個代碼不工作)作爲參數在角度點擊方法中的表達
我想給特定的機票的ID在生成的表列到我的背結束Java控制器並調用reject()
方法。任何想法如何達到這個功能「clean」的方式?
<tr ng-repeat="ticket in tickets" ng-show="ticket.state === 'NEW' || ticket.state === 'PROCESSING'">
<td>{{ticket.created}}</td>
<td style="text-align: center;">
<a href="#" ng-click="rejectTicket({{ticket.id}})">
<img class="ico" src="../lib/images/reject.png" title="Reject ticket">
</a>
<a href="#" ng-hide="ticket.state === 'PROCESSING'">
<img class="ico" src="../lib/images/incrase.png" title="Change to processing">
</a>
<span ng-show="ticket.state === 'PROCESSING'">
<img class="ico" src="../lib/images/incraseDisabled.png" title="Already processing">
</span>
<a href="#">
<img class="ico" src="../lib/images/approve.png" title="Satisfy ticket">
</a>
</td>
</tr>
EDIT 1 控制器代碼添加波紋管。
angular.module('app').controller('TicketController', function ($scope, $http, $location) {
$scope.tickets = [];
/**
* Get tickets.
*/
$http.get('rest/tickets').then(function (response) {
$scope.tickets = response.data;
});
/**
* Create a ticket.
*/
$scope.createTicket = function() {
console.log('submit');
$http({
url: 'rest/tickets',
method: "POST",
data: $scope.ticket
}).then(function (response) {
$scope.tickets.push(response.data);
}, function() {
alert('Error: New ticket was not created.');
}).finally(function() {
$scope.ticket = {
state: 'NEW'
};
})
};
/**
* Reject a ticket.
*/
$scope.rejectTicket = function (ticketId) {
console.log('submit');
$http({
url: 'rest/tickets/reject',
method: "PUT",
data: ticketId
}).then(function (response) {
$scope.tickets.push(response.data);
}, function() {
alert('Error: Can not reject this ticket.');
}).finally(function() {
$scope.ticket = {};
})
};
});
安置自己的控制器代碼 – Sajeetharan