gpt4 book ai didi

angularjs - Angular JS 路由不起作用,只显示部分路径,而不是部分路径

转载 作者:行者123 更新时间:2023-12-04 17:10:38 25 4
gpt4 key购买 nike

我正在学习 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/开始.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>

最佳答案

使用 templateUrl而不是 template

关于angularjs - Angular JS 路由不起作用,只显示部分路径,而不是部分路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15748307/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com