2013-08-18 38 views
1

我有我的應用程序設置與視圖的路線,一個$routeProvider爲:角是印刷的,而不是渲染局部的

angular.module('myApp', []) 

    .config(['$routeProvider', function($routeProvider){ 
     $routeProvider 
      .when('/authorisation', { template: 'templates/authorisation.html', controller: AuthenticationController}) 
      .otherwise('templates/404.html'); 
    }]); 

index.html是:

<!DOCTYPE html> 
<html lang="en" ng-app="myApp"> 
<head> 
    <title>Gift Cloud Dash</title> 
    <script src="lib\angular\angular.js"></script> 

    <!-- App config --> 
    <script src="js\app.js"></script> 

    <!-- Import controllers --> 
    <script src="js\controllers\authentication-controller.js"></script> 
</head> 
<body> 
<div> 
    <a href="#/authorisation">Authorisation</a> 
</div> 
<div ng-view></div> 
</body> 
</html> 

當我打開索引頁面,我看到超鏈接,但是當我單擊它時,將顯示文件路徑而不是它在<div ng-view></div>中呈現。

Angular displaying resourse path.

+1

使用'templateUrl',而不是'模板' – madhead

+0

乾杯,不知道我從那裏得到了! – BanksySan

回答

4

固定它,我會離開這裏萬一別人得到了相同的症狀:

在我的路由配置的語法是錯誤的:它應該是:

angular.module('myApp', []) 

    .config(['$routeProvider', function($routeProvider){ 
     $routeProvider 
      .when('/authorisation', { templateUrl: 'templates/authorisation.html', controller: AuthenticationController}) 
      .otherwise({redirectTo: 'templates/404.html'}); 
    }]);