Angular uiRouter 使用 stateParams 在新窗口或选项卡中打开状态

2024-03-13

我想做的是在新选项卡或新窗口中执行以下操作:

$state.go('studentsReport', {
       type: $scope.report.type, // string
       selectedStudents: $scope.selectedStudents // array of strings
});

如果我这样做:

var link = $state.href('studentsReport', {
       type: $scope.report.type,
       selectedStudents: $scope.selectedStudents
});

window.open(link, '_blank');`

我会丢失参数。

此致, 马塞尔


你应该尝试使用这个:

/* @ngInject */
function SomeCtrl ($state, $window) {
  $window.open($state.href('stateName', {}, {absolute: true}), '_blank');
}

注:/* ngInject */如果使用 ng-annotate (可在cli https://github.com/olov/ng-annotate, gulp https://www.npmjs.com/package/gulp-ng-annotate/, and grunt https://www.npmjs.com/package/grunt-ng-annotate口味)

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Angular uiRouter 使用 stateParams 在新窗口或选项卡中打开状态 的相关文章

随机推荐