2014-07-12 110 views
0

这是我route.js:AngularJS路由失败

var app = angular.module('tradePlace', ['ngRoute', 'tradeCntrls']); 
app.config(['$routeProvider', '$locationProvider', function($route, $location) { 
    $route. 
    when('/', { 
     redirectTo: '/index' 
    }). 
    when('/index', { 
     templateUrl: './includes/templates/index.html', 
     controller: 'indexCntrl' 
    }). 
    when('/register', { 
     templateUrl: './includes/templates/register.html', 
     controller: 'registerCntrl' 
    }). 
    when('/home', { 
     templateUrl: './includes/templates/home.html' 
    }). 
    when('/registerCompleted/:email', { 
     templateUrl: './includes/templates/registerCompleted.html', 
     controller: 'activationInstrCntrl' 
    }). 
    otherwise({ 
     redirectTo: '/index' 
    }); 

    $location.html5Mode(true); 
}]) 

这是activationInstCntrl:

var app = angular.module('tradeCntrls'); 
app.controller('activationInstrCntrl', ['$scope', '$routeParams', function($scope, $route){ 
    $scope.email = $route.email; 
}]) 

而且模板:

hi {{email}} 

当我去mysite.com/路由器做他的工作,但当我去mysite.com/registerCompleted/hi我得到一个空白页和一些奇怪的错误在利弊ole:

Uncaught SyntaxError: Unexpected token < routes.js:1 Uncaught SyntaxError: Unexpected token < loginService.js:1 Uncaught SyntaxError: Unexpected token < registerService.js:1 Uncaught SyntaxError: Unexpected token < indexCntrl.js:1 Uncaught SyntaxError: Unexpected token < registerCntrl.js:1 Uncaught SyntaxError: Unexpected token < activationInstrCntrl.js:1 Uncaught object

我有搜索,但我找不到为什么我得到的错误和解决方案是什么?

回答

0

我想你的后端试图找到另一条路径

尝试使用锚(#)加入网址,或者您需要定义htaccess的规则

+0

你能在“使用连接的URL提供了一个例子一个主播“,请问? –