Javascript 在AngularJS中调用Ajax后不更新视图?

Javascript 在AngularJS中调用Ajax后不更新视图?,javascript,angularjs,Javascript,Angularjs,我正在调用get方法,但视图未更新。我尝试了alert(),它正确地显示了数据 var-app=angular.module('test',[]); app.controller('TestCtrl',函数($scope) { $.get(“people/allNumberOfuser”,函数(数据) { $scope.testValue=data.message; 警报(数据、消息); }); }); {{testValue}} JQuery get callback方法不通过angu

我正在调用get方法,但视图未更新。我尝试了
alert()
,它正确地显示了数据

var-app=angular.module('test',[]);
app.controller('TestCtrl',函数($scope)
{
$.get(“people/allNumberOfuser”,函数(数据)
{
$scope.testValue=data.message;
警报(数据、消息);
});
});

{{testValue}}


JQuery get callback方法不通过angular进行检测,因为它在angular之外,所以需要使用
$scope.$apply()

var-app=angular.module('test',[]);
app.controller('TestCtrl',函数($scope)
{
jQuery.get(“/People/GetNumberOfUser”),函数(数据)
{
$scope.testValue=data.message;
$scope.$apply();
警报(数据、消息);
});
});

{{testValue}}


使用AngularJS的
$http
服务进行http调用。请阅读更多关于它的信息。首先,在AngularJS不要考虑使用jQuery。这能回答你的问题吗?@31谢谢,我已经使用
$http
服务更新了我的编码