AngularJS hashbang模式复制URL路径


AngularJS hashbang mode duplicating URL path

我正在开发一个带有Laravel 4后端的AngularJS应用程序。为了支持IE,我最近不得不在$locationProvider服务中从html5切换到hashbang模式。该应用程序可以工作,但在所有浏览器中,hashbang之后的URL路径都是重复的。

示例-http://domain.com/resources/resource显示为http://domain.com/resources/resource#/资源/资源

我在下面列出了我的主要模块。如有任何协助,我们将不胜感激。

angular.module('agent', ['agent.controllers', 'agent.directives', 'ngRoute']).
    config(['$routeProvider', '$locationProvider',
    function($routeProvider, $locationProvider) {
        //   
        $locationProvider.hashPrefix('!');
        $routeProvider
            .when('/resources/resource', {
                template: templatePath,
                controller:  'ResourcessController'
            })
            .otherwise({redirectTo: '/resources/resource'});
    }]);

我已经多次看到这个问题。作为一个变通办法,我发现的唯一一件事就是直接转发到有角度的页面。以以下为例:

http://example.com/product/1234#/1234

如果这来自另一个页面,您可以直接链接到哈希链接:

http://example.com/product#/1234

现在URL没有重复,例程仍然按预期工作。基本上,这里的重点是根据这是服务器/控制器页面还是客户端/角度页面进行路由。我不确定这是否真的是最好的答案,因为我还在学习角度。希望其他人也有很好的建议!