gpt4 book ai didi

javascript - 需要帮助检查 Angular ui-router 代码

转载 作者:行者123 更新时间:2023-12-03 06:39:54 24 4
gpt4 key购买 nike

我正在尝试以 Angular 创建投资组合,但似乎无法获得正确的路由。我仔细检查了我之前制作的应用程序,似乎找不到任何东西。当我编译时,控制台中没有记录任何错误。有人可以检查我的代码是否正确排列吗?

HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>my portfolio</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="stylesheet.css">

<!-- <link href="https://fonts.googleapis.com/css?family=Titillium+Web:300' rel='stylesheet' type='text/css"> -->
</head>

<body np-app="myPort">
<div id="navigation-bar">
<ul>
<li><a href="#/home">Home</a></li>
<li><a href="#/projects">My Projects</a></li>
<li><a href="#/contact">Contact</a></li>
</ul>
</div>

<div ui-view></div>

<!-- loading angular frameworks -->
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js"></script>
<script src="bower_components/angular-ui-router/release/angular-ui-router.js"></script>
<script src="bower_components/jquery/dist/jquery.js"></script>
<script src="bower_components/bootstrap/dist/js/bootstrap.js"></script>
<!-- app js stuff -->
<script src="app.js"></script>
</body>
</html>

模块

angular.module('myPort', ['ui.router'])

.config(['$stateProvider', '$urlRouterProvider', function($stateProvider, $urlRouterProvider) {
$stateProvider
.state('home', {
url: '/home',
templateUrl: 'partials/bio/index.html',
})

.state('projects', {
url: '/projects',
templateUrl: 'partials/projects/index.html',
})

.state('contact', {
url: '/contact',
templateUrl: 'partials/contact/index.html',
})

$urlRouterProvider.otherwise('/home');
}]);
//no controllers linked for troubleshooting

最佳答案

定义 ng-app 时出现拼写错误.

更改<body np-app="myPort>"<body ng-app="myPort>"

关于javascript - 需要帮助检查 Angular ui-router 代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38008087/

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