這是用HTML視圖和模型的角度控制器類基本角度web應用
我的角度控制腳本文件包含
var taskResource = $resource("http://localhost:3000/api/tasks/:id", { id: '@id' });
$scope.tasks = taskResource.query();
noError = function() {
$scope.error = "";
}
onFailure = function() {
$scope.error = "Error communicating with server";
}
$scope.changeTaskDone = function (task) {
$scope.tasks.$save(task, noError, onFailure);
};
我的HTML包含
<tr ng-class="{'task-done': task.done}" ng-repeat="task in tasks | orderBy: '-priority'">
<td class="small-cell">
<button type="button" class="btn btn-xs btn-danger" ng-click="deleteTask(task)">
<span class="glyphicon glyphicon-remove"></span>
</button>
</td>
<td class="small-cell">
<input type="checkbox" ng-model="task.done" ng-change="changeTaskDone(task)" />
</td>
noError和OnFailure回調沒有被調用。
編輯 localhost是我開發的一個節點服務器。我應該從節點服務器發送什麼信息才能使成功回調在客戶端激活。 現在它只發送一個res.status(200);
找不到或未被調用的方法?你有任何錯誤信息? –
這些方法沒有被調用。我使用視覺工作室。如果將調試點放在onError和onFailure上,並且在我停止本地主機服務器時未命中 –
,則會調用OnFailure。所以錯誤回調正在工作。但成功回調NoError不是。 –