我正在开发一个依赖于angularjs并且无法实现angular-ui-router framework
的django项目。
正如文档中所提到的,我将ui.router
作为依赖项,
app = angular.module('myApp',['restangular','ui.router',])
配置状态如下,
app.config(['$stateProvider',function($stateProvider){
$stateProvider.state('landing',{
url: '/',
template:"<p> somethings here.</p>"
})
}]);
在base.html
文件中的我根据需要使用angularjs引导django项目
ng-app=myApp
。
和index.html
继承base.html
<div ui-view>
<i>nothing here but this text</i>
</div>
我的urls.py
,
url(r'^$',home,name="homepage")
这不起作用,ui-router
从不在inline template
中包含index.html
。 index.html
始终加载nothing here but this text
。我看过这里提出的问题,但没有帮助。我错过了什么,这是django特有的吗?
答案 0 :(得分:1)
我会说这些行应该成功:
app.config(['$urlRouterProvider',function($urlRouterProvider){
$urlRouterProvider.otherwise('/');
}]);
检查工作plunker here
同时检查: