【发布时间】:2016-10-19 03:30:59
【问题描述】:
我是一个新的 AngularJs 开发者,我正在使用 Spring MVC 和 angularJs 开发一个 java web 应用程序。
我想在我的项目中包含 ui-router,但我遇到了一些问题。
我正在尝试了解嵌套状态如何与 AngularJs 中的 ui-router 一起工作。但是,它不起作用。事实上,ui-routing 不起作用,我不知道为什么
我制作了一个示例测试项目,结构如下:
这是我的 index.html 文件
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<script src="js/angular.min.js"></script>
<script src="js/angular-ui-router.min.js"></script>
<script src="js/app.js"></script>
<title>Test angularJs Nesting</title>
</head>
<body ng-app="example">
This is the index level
<br>
<div ui-view></div>
</body>
</html>
这是我的 app.js 文件
var example=angular.module("example", ['ui.router']);
example.config(function($stateProvider, $urlRouterProvider){
$stateProvider
.sate("settings", {
url: "/settings",
templateUrl: "templates/settings.html"
})
.sate("settings.profile", {
url: "/profile",
templateUrl: "templates/profile.html"
})
.sate("settings.account", {
url: "/account",
templateUrl: "templates/account.html"
});
$urlRouterProvider.otherwise("/settings/profile");
});
这是我的 settings.html 文件
This is our settings layout
<br>
<a ui-sref="settings.profile">Show Profile</a>
<a ui-sref="settings.account">Show Account</a>
<div ui-view></div>
这是我的 profile.html 文件
<div>
This is a profile page
</div>
这是我的 account.html 文件
<div>
This is a account page
</div>
我希望 settings.html 的内容显示在 ui 视图上。但事实并非如此。什么都没有显示
请问,我的示例中缺少什么?我丢失了一些 angularJs 配置吗?
提前感谢您的回答
【问题讨论】:
标签: javascript java html angularjs spring-mvc