Angular-ui-router没有使用django呈现模板

时间:2022-01-13 19:42:01

I am working on a django project that relies on angularjs and having trouble implementing angular-ui-router framework.

我正在开发一个django项目,该项目依赖于angularjs,在实现angular-ui-router框架时遇到了麻烦。

As mentioned in documentation I have included ui.router as a dependency,

正如在文档中提到的,我已经包括了ui。路由器作为一个依赖,

app = angular.module('myApp',['restangular','ui.router',])

configured the states as follows,

配置状态如下,

app.config(['$stateProvider',function($stateProvider){
    $stateProvider.state('landing',{
      url: '/',
      template:"<p> somethings here.</p>"
    })
  }]);

in base.html file i bootstrap the django project with angularjs as required ng-app=myApp.

在基地。html文件i根据需要使用ng-app=myApp引导django项目。

and in index.html which inherits base.html

和索引。html的继承base.html

<div ui-view>
  <i>nothing here but this text</i>
</div>

my urls.py,

我的urls . py,

url(r'^$',home,name="homepage")

This does not work, ui-router never includes the inline template in index.html. index.html always loads nothing here but this text. I have looked at as much questions asked here but are not helping. What am I missing, is this specific to django?

这不起作用,ui-router也没有包含index.html中的内联模板。索引。html总是在这里只加载文本。我看了这里问的问题,但没有帮助。我错过了什么,这是针对django的吗?

1 个解决方案

#1


1  

I would say that these lines should make it:

我想说,这几行应该是:

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

Check the working plunker here

检查这里的工作柱塞

Also check:

也检查:

#1


1  

I would say that these lines should make it:

我想说,这几行应该是:

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

Check the working plunker here

检查这里的工作柱塞

Also check:

也检查: