jac*_*per 6 angularjs angularjs-routing angular-ui-router
我跟着这篇文章和另一篇文章,我试图复制维基上的内容,没有任何运气.
到目前为止,这就是我所做的文件夹结构:
stateProvider:
angular.module('app').config(function($stateProvider, $urlRouterProvider) {
$stateProvider.state("index",
{
url: "/index",
templateUrl:'/partial/index.html',
views: {
'footer@index': {
templateUrl: "/partial/header.html",
controller:"FooterCtrl"
},
'header@index': {
templateUrl: "/partial/header.html",
controller: "HeaderCtrl"
}
}
});
$urlRouterProvider.otherwise('/index');
Run Code Online (Sandbox Code Playgroud)
编辑:
这是标记:
<div>
<div id="content" class="container">
<div ui-view="header"></div>
<div ui-view></div>
<div ui-view="footer"></div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我正在浏览的网址是:localhost:9001 /#/ index
我没有任何错误只是一个空白页面
看起来您在 templateUrl 上使用了不正确的路径。
这是使用 ui-router 的 plunker:http://plnkr.co/edit/Nqwlkq1vGh5VTBid4sMv ?p=preview
我还建议阅读http://angular-ui.github.io/ui-router/sample/#/的源代码,它在这里有一个抽象实现,以及许多关于如何正确使用 ui-router 的评论。
| 归档时间: |
|
| 查看次数: |
3912 次 |
| 最近记录: |