2013-05-19 58 views
0

我正在开发一个webapp使用AngularJSLaravelAngularJS - 直接访问网址与散列

当我通过在应用程序的一切网址和链接导航工作正常,但如果我直接在浏览器中键入URL的,奇怪的事情发生了。

例如,如果键入http://myapp.dev/#/customers我重定向到http://myapp.dev/customers#/

为什么?怎么了? Laravel执行“/”路由(右)和Angular“/”路由(再次右移)。

注:我也有类似的第一,但没有使用Laravel和的.htaccess测试应用程序(它仅用静态HTML)和我没有这个问题,我可以直接访问网址。

谢谢。

编辑 - 这里的角路由代码:

 
var App = angular.module('Factotum', ['ngResource']); 

function appRouteConfig($routeProvider) { 
    $routeProvider. 

    when('/', { 
     controller: IndiceController, 
     templateUrl: 'v/indice' 
    }). 
    when('/login', { 
     controller: 'AppController', 
     templateUrl: 'v/login' 
    }). 
    when('/logout', { 
     controller: 'AppController', 
     templateUrl: 'v/login' 
    }). 
    // ---- Clienti 
    when('/clienti', { 
     controller: ClientiController, 
     templateUrl: 'v/clienti/lista' 
    }). 
    when('/clienti/nuovo', { 
     controller: ClientiController, 
     templateUrl: 'v/clienti/nuovo' 
    }). 
    when('/clienti/modifica/:id', { 
     controller: ClientiController, 
     templateUrl: 'v/clienti/modifica' 
    }). 
    // ---- Progetti 
    when('/progetti', { 
     controller: ProgettiController, 
     templateUrl: 'v/progetti/lista' 
    }). 
    when('/progetti/nuovo', { 
     controller: ProgettiController, 
     templateUrl: 'v/progetti/nuovo' 
    }). 
    otherwise({ 
     redirectTo: '/' 
    }); 
} // factotumRouteConfig 

App.config(appRouteConfig); 
+0

编辑:如果我浏览到http://myapp.dev/#customers我得到重定向到http://myapp.dev/#/customers(ok) – eleftrik

+0

你使用的是angular的html5Mode吗? – Ven

+1

你可以显示你的路由代码吗? – Reza

回答

1

最后我发现这个问题。我使用的是免费的HTML5模板(魅力通过乌斯曼 - 在这里演示:http://usman.it/themes/charisma/),其中包括的jQuery插件历史。我删除了这个插件,以及一些初始化代码,现在全部按预期工作。 我的错,我没有仔细检查代码。