我正在关注关于 AngularJS 的教程 - “使用 AngularJS 构建网站”
我使用的路线与教程几乎相同:
// JavaScript Document
angular.module('quest', []).
config(function($routeProvider) {
$routeProvider.
when('/about', {template:'partials/about.html'}).
when('/start', {template:'partials/start.html'}).
otherwise({redirectTo:'/home', template:'partials/home.html'});
});
问题是:它只显示资源的路径,而不是资源的内容,所以不显示 html 内容,它只显示:
PARTIALS/ABOUT.HTML
我不确定我做错了什么,但它确实有效,如果我转到 #/about URL,它会显示“PARTIALS/ABOUT.HTML”,如果我将 url 更改为 index.html#/start,它会显示“PARTIALS/开始.HTML"
页面的html:
<!DOCTYPE html>
<html lang="en" ng-app="quest">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="format-detection" content="telephone=no" />
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
<link rel="stylesheet" type="text/css" href="css/index.css" />
<title></title>
</head>
<body ng-controller="MainController">
<script type="text/javascript" src="js/angular.min.js"></script>
<script type="text/javascript" src="js/quest.js"></script>
<div ng-view></div>
</body>
</html>