admin管理员组文章数量:1353467
What I want to do is following in but in a new Tab or new Window:
$state.go('studentsReport', {
type: $scope.report.type, // string
selectedStudents: $scope.selectedStudents // array of strings
});
If I did:
var link = $state.href('studentsReport', {
type: $scope.report.type,
selectedStudents: $scope.selectedStudents
});
window.open(link, '_blank');`
I would lose the parameters.
Best regards, Marcel
What I want to do is following in but in a new Tab or new Window:
$state.go('studentsReport', {
type: $scope.report.type, // string
selectedStudents: $scope.selectedStudents // array of strings
});
If I did:
var link = $state.href('studentsReport', {
type: $scope.report.type,
selectedStudents: $scope.selectedStudents
});
window.open(link, '_blank');`
I would lose the parameters.
Best regards, Marcel
Share Improve this question edited May 16, 2015 at 17:38 molerat asked May 16, 2015 at 14:35 moleratmolerat 9944 gold badges17 silver badges44 bronze badges2 Answers
Reset to default 5You should trying to use this:
/* @ngInject */
function SomeCtrl ($state, $window) {
$window.open($state.href('stateName', {}, {absolute: true}), '_blank');
}
Note: the /* ngInject */
facilitates automatic dependency injection annotation if using ng-annotate (available in cli, gulp, and grunt flavours)
use ng-click on link tag and call a function. in function put your parameters in LocalStorage. then in app.run use $rootScope.$on("$stateChangeStart") and check if localstorage have parameters get params and call $state with params.
//in page controller:
var openNewTab = function () {
localStorage.newTab = JSON.stringify({
state: "yourState",
params: {
param1: "someparam1",
param2:"someparam2"
}
});
window.open(document.location.origin);
}
//angular app run config:
angularApp.run(function($state){
if(localStorage.newTab){
var newTab = JSON.parse(localStorage.newTab);
localStorage.removeItem("newTab");
$state.go(newTab.state, newTab.params);
event.preventDefault();
}
})
<a ng-click="openNewTab()" >open new tab</a>
本文标签: javascriptAngular uiRouter open state in new window or tab with stateParamsStack Overflow
版权声明:本文标题:javascript - Angular uiRouter open state in new window or tab with stateParams - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743895249a2557665.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论