Javascript angular.js$scope.$apply不适用于ng repeat

Javascript angular.js$scope.$apply不适用于ng repeat,javascript,angularjs,apply,digest,Javascript,Angularjs,Apply,Digest,这在我使用$scope时一直有效。$apply用于$http请求,我在这方面缺少什么? 我首先得到了“Digest cycle is Early in progress”(摘要周期已在进行中)消息,然后添加了setTimeout(),它去掉了该消息,但仍然不能用数据更新。这不应该是个问题,我显然遗漏了什么 HTML: <form name="userDataForm" role="form" ng-submit="submit()"> <input type="text" na

这在我使用$scope时一直有效。$apply用于$http请求,我在这方面缺少什么? 我首先得到了“Digest cycle is Early in progress”(摘要周期已在进行中)消息,然后添加了setTimeout(),它去掉了该消息,但仍然不能用数据更新。这不应该是个问题,我显然遗漏了什么

HTML:

<form name="userDataForm" role="form" ng-submit="submit()">
<input type="text" name="userId" placeholder="Enter User ID" ng-model="viewModel.useId" />
<input type="text" name="start" placeholder="Start Date: dd-mm-yyyy" ng-model="viewModel.startDate"/>
<input type="text" name="end" placeholder="End Date: dd-mm-yyyy" ng-model="viewModel.endDate"/><br/>

<button type="submit">
    Get Data
</button>
<ul ng-repeat="place in viewModel.userData.data.significant_places">
    <li>
        You have been at <span style="color:red;">{{place.name}}</span> <span style="color:red;">{{place.number_of_days}}</span> days this month
    </li>
<ul>

这应该很好:

$scope.viewModel = {
    userId:'',
    startDate:'',
    endDate:'',
    userData:{}
};
$scope.submit = function(){

    $http.get('http://localhost:3000/?user_id=279&start=20150101&end=20150113').success(function(data){
        $scope.viewModel.userData = data;
    }).error(function(){
        console.log('error');
    });

};

很少有实例需要自己使用
$scope.$apply
。Angular几乎总是为你做这件事(这就是为什么你会犯这个错误)。

你应该在这里添加一些关于你目标的信息。本能地,我认为这不是最简单的方法。你到底为什么要用
$apply
来包装你的http调用?您返回的数据是否也包含
数据:{重要位置:[…
?谢谢,最后这是我的问题,我搜索了错误的json结构。我的错。
$scope.viewModel = {
    userId:'',
    startDate:'',
    endDate:'',
    userData:{}
};
$scope.submit = function(){

    $http.get('http://localhost:3000/?user_id=279&start=20150101&end=20150113').success(function(data){
        $scope.viewModel.userData = data;
    }).error(function(){
        console.log('error');
    });

};