嘿我正在开发一个涉及django和angular的web开发教程,我遇到了一个问题,即使在本地服务器上运行时我的angularJS路由也无法工作......所以会发生什么是index.html加载背景图像和导航栏,但其余的html不存在。
这是我的代码:
的index.html
<!DOCTYPE html>
<html ng-app="thinkster">
<head>
<title>HRLite Home</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<base href="/" />
<!-- Fonts -->
<link href='https://fonts.googleapis.com/css?family=Lobster|Raleway:500' rel='stylesheet' type='text/css'>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<!-- Scripts -->
{% include 'javascripts.html' %}
{% include 'stylesheets.html' %}
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.5/angular.min.js"></script>
<script src="https://code.angularjs.org/1.2.28/angular-route.min.js"></script>
<script src="static/javascripts/thinkster.routes.js"></script>
</head>
<body>
{% include 'navbar.html' %}
<div ng-view></div>
</body>
</html>
thinkster.js
(function () {
'use strict';
angular
.module('thinkster', [
'thinkster.config'
'thinkster.routes',
'thinkster.authentication'
]);
angular
.module('thinkster.config, []');
angular
.module('thinkster.routes', ['ngRoute']);
angular
.module('thinkster')
.run(run);
run.$inject = ['$http'];
/**
* @name run
* @desc Update xsrf $http headers to align with Django's defaults
*/
function run($http) {
$http.defaults.xsrfHeaderName = 'X-CSRFToken';
$http.defaults.xsrfCookieName = 'csrftoken';
}
})();
thinkster.routes.js
(function () {
'use strict';
angular
.module('thinkster.routes')
.config(config);
config.$inject = ['$routeProvider'];
/**
* @name config
* @desc Define valid application routes
*/
function config($routeProvider) {
$routeProvider
.when('/', {
templateUrl "static/templates/authentication/home.html"
}).when('/register', {
controller: 'RegisterController',
controllerAs: 'vm',
templateUrl: '/templates/authentication/register.html'
}).when('/login', {
controller: 'LoginController',
controllerAs: 'vm',
templateUrl: '/templates/authentication/login.html'
}).otherwise('/'();
}})();
我对角度很新,所以它可能是我犯过的一个愚蠢的错误!如果有人可以提供帮助,将不胜感激!