direct access to url with hash
I'm developing a webapp using AngularJS and Laravel .
When I navigate through URL and links in the app everything works fine, but if I type an URL directly in the browser, something strange happens.
For example, If I type http://myapp.dev/#/customers I get redirected to http://myapp.dev/customers#/
Why? What's wrong? Laravel executes "/" route (right) and Angular "/" route (right, again).
Note: I have made a test application similar to the first but without using Laravel and .htaccess (it serves only static HTML) and I haven't this issue, I can access URL directly.
Thank you.
Edit - here the Angular routing code:
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);
Finally I found the problem. I'm using a free HTML5 template ( Charisma by Usman - here a demo: http://usman.it/themes/charisma/), which includes jQuery History plugin . I removed this plugin, along with some initialization code, and now all is working as expected. My fault, I didn't inspect the code carefully.
链接地址: http://www.djcxy.com/p/77602.html上一篇: 点击不会触发我的方法
下一篇: 用哈希直接访问url
