Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/451.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 打印从http rfequest动态更新的页面范围_Javascript_Angularjs_Http - Fatal编程技术网

Javascript 打印从http rfequest动态更新的页面范围

Javascript 打印从http rfequest动态更新的页面范围,javascript,angularjs,http,Javascript,Angularjs,Http,我正在打印一个html页面。我正在使用angular.js。我有一个获取数据的http请求。我有一个问题,打印区域没有用第一个http请求更新: http.post(url,data).then(function(result) { $scope.data = result.data; print($("#printarea").html()); }); 有人知道为什么会这样吗?DOM更新后如何调用打印函数?我认为打印前需要使用$scope.$apply(),如下所示: ht

我正在打印一个html页面。我正在使用angular.js。我有一个获取数据的http请求。我有一个问题,打印区域没有用第一个http请求更新:

http.post(url,data).then(function(result) {
    $scope.data = result.data; 
    print($("#printarea").html());
});

有人知道为什么会这样吗?DOM更新后如何调用打印函数?

我认为打印前需要使用$scope.$apply(),如下所示:

http.post(url,data).then(function(result)
{
   $scope.data=result.data;
   $scope.$apply(); 
   print($("#printarea").html());
});

谢谢你的重播。但这会引发一个错误[$rootScope:inporg]不适用于任何其他解决方案?您可以使用大约2-3秒的超时时间。您可以在这里发布一个示例吗?当然可以。请参考此链接。