我有刪除項目的場景。 爲此,首先我得到一個具有特定條件的值列表。檢索值將在UI中用單選按鈕顯示,以選擇要刪除的特定項目。角度範圍內的值越來越未定義
我已經給出了單選按鈕的值作爲檢索到的項目的ID。這個id用於angularJS方法中的刪除。目前在控制器內部的角度函數中獲得未定義的值。
我的角度控制器是如下:
mainApp.controller("deleteToDoController", function($scope,$http) {
$scope.toDoList = {};
$scope.getToDo = function(){
var url = "http://localhost:8080/webservice-4.0/rest/todo/"+$scope.status;
$http.get(url)
.then(function(response) {
$scope.toDoList = angular.fromJson(response.data);
});
}
$scope.deleteToDo = function(){
var url = "http://localhost:8080/webservice-4.0/rest/todo/delete/"+$scope.deleteId;
$http.get(url)
.then(function(response) {
$scope.toDoList = angular.fromJson(response.data);
});
}
});
我的HTML頁面的代碼是:
<div ng-controller="deleteToDoController">
<form ng-submit="getToDo()">
ToDo Status:
<input type="radio" ng-model="status" value="completed"/>Completed<input type="radio" ng-model="status" value="pending"/>Not Completed
<input type="submit" value="View To Do"/><br>
<div ng-repeat = "toDo in toDoList">
<input type="radio" ng-model="deleteId" value="{{toDo.id}}"/>Task : {{toDo.name}}<br>
</div>
<input type="button" ng-click="deleteToDo()">Delete</button><br>
</form>
讚賞!!!!
你得到了一個未定義在哪裏? – Sajeetharan
@Sajeetharan在deleteToDo()方法中獲取undefined。 –