Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/24.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 AngularJS:$location.path(';/newLocation';)是同步的还是异步的?_Javascript_Angularjs - Fatal编程技术网

Javascript AngularJS:$location.path(';/newLocation';)是同步的还是异步的?

Javascript AngularJS:$location.path(';/newLocation';)是同步的还是异步的?,javascript,angularjs,Javascript,Angularjs,我正在尝试扩展现有的AngularJS应用程序。在旧版本中,开发人员按下表单按钮generatereport时会显示一个隐藏的div。现在由于用例的变化,有必要将这个div放在一个单独的视图中并动态切换到它。因此,我在controllerreportDetails.html中创建了一个新视图,它工作正常。隐藏视图最初不显示,因为它需要设置一些值 旧版本从“生成报告”视图执行此操作: 我是否必须等待$location.path('/reportDetails')完成,即它是同步调用还是异步调用?更

我正在尝试扩展现有的AngularJS应用程序。在旧版本中,开发人员按下表单按钮
generatereport
时会显示一个隐藏的
div
。现在由于用例的变化,有必要将这个
div
放在一个单独的视图中并动态切换到它。因此,我在controller
reportDetails.html
中创建了一个新视图,它工作正常。隐藏视图最初不显示,因为它需要设置一些值

旧版本从“生成报告”视图执行此操作:


我是否必须等待
$location.path('/reportDetails')完成,即它是同步调用还是异步调用?

更改视图是一项非常复杂的操作,并且由于很多原因是异步的,例如模板解析、状态解析中的解析承诺等@PetrAveryanov,那么,解决此用例的正确方法是什么?在state-paramChanging视图中传递初始输入值是一个非常复杂的操作,并且由于很多原因是异步的,比如模板解析、在state-Resolve中解析承诺等等@PetrAveryanov那么,解决这个用例的正确方法是什么呢?在状态参数中传递初始输入值
<td class="selection-fields-report">
   <label class="invisible">Dummy</label><br>
   <button class="btn btn-primary" ng-click="generateReport()" ng-disabled="reportData.notReadyForReport">Generate Report</button>
</td>
$scope.generateReport = function () {
   // ...
   // switch to the report details
   $location.path('/reportDetails');
   // but this 'filterStr' element is not yet available????
   document.getElementById('filterStr').value = "";
   // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error here filterStr doesn't exist ... but it is in the new view reportDetails.html