Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
426 views
in Technique[技术] by (71.8m points)

javascript - AngularJS重定向控制器和历史记录返回问题(AngularJS redirect controller and history back issue)

I need help with external redirecting in AngularJS.(我需要有关AngularJS外部重定向的帮助。)

This is my route:(这是我的路线:)

$routeProvider.when('/route1/', {
    template: html_externalRedirect,
    resolve: resolver(['core/controllers/ExternalRedirectController'])
});

This is my redirect controller:(这是我的重定向控制器:)

define(['myApp',], function (myApp) {
   'use strict';
   myApp.lazy.controller('ExternalRedirectController', ['$location', '$window',
       function ($location, $window) {
          $window.location = baseUrl + $location.path();
   }]);
});

Redirect works successfully, but when I click 'back' browser button, it redirects me to 'not found' page.(重定向成功完成,但是当我单击“后退”浏览器按钮时,它会将我重定向到“未找到”页面。)

Seems like, records in window history are wrong.(好像,窗口历史记录中的记录是错误的。) Could anyone help me solve this issue?(谁能帮我解决这个问题?)   ask by Dmytro Pavliuchenko translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

It may be because you didn't define the default route to $routeProvider.(可能是因为您没有定义到$ routeProvider的默认路由。)

Please add either of two options to solve this problem:(请添加两个选项之一来解决此问题:)
  • .when("/", { template: html_externalRedirect })
  • otherwise({ template: html_externalRedirect });(否则({template:html_externalRedirect});)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...