我在服务中有这个:
UpdateQuestionsSmsStatus: function (smsProfileId, active) {
//TODO: ajax get data
var promise = this.UpdateQuestionsSmsStatusInternal(smsProfileId, active).then(function (response) {
// The return value gets picked up by the then in the controller.
return response;
});
// Return the promise to the controller
return promise;
},
UpdateQuestionsSmsStatusInternal: function (smsProfileId, active) {
return $http({ method: 'GET',
url: '../QuestionManagement/UpdateQuestionsSmsStatus?smsProfileId=' + smsProfileId + '&active=' + active
}).
success(function (data, status, headers, config) {
// this callback will be called asynchronously
// when the response is available
response = data;
}).
error(function (data, status, headers, config) {
// called asynchronously if an error occurs
// or server returns response with an error status.
if (window.console && console.log) {
console.log("Could not obtain questions received. Error:" + data + "Status:" + status + "Headers:" + headers + "Config:" + config);
}
});
},
这在我的控制器中:
$scope.updateQuestionsSmsStatus = function () {
questionSelectionService.UpdateQuestionsSmsStatus($scope.smsProfile.Id, !$scope.smsProfile.Active).then(function (output) {
$scope.smsProfile.Active = (output.data.result == "success") ? output.data.active : !output.data.active;
});
};
从视图中称为 onclick。这在视图中:
{{smsProfile.Active}}
视图中的值永远不会更新。调试器没有显示任何错误,也没有出现错误。
有没有人有任何想法?谢谢你。