Angular-ui-router没有使用django渲染模板

时间:2014-09-22 17:51:42

标签: django angularjs angular-ui angular-ui-router

我正在开发一个依赖于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.htmlindex.html始终加载nothing here but this text。我看过这里提出的问题,但没有帮助。我错过了什么,这是django特有的吗?

1 个答案:

答案 0 :(得分:1)

我会说这些行应该成功:

app.config(['$urlRouterProvider',function($urlRouterProvider){
    $urlRouterProvider.otherwise('/');
  }]);

检查工作plunker here

同时检查: