我正在关注AngularJS –
“Building a website with 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 /的start.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>