2014-09-22 94 views
2

我正在使用一個django項目,該項目依賴於angularjs並且難以實現angular-ui-router frameworkAngular-ui路由器沒有用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文件I引導與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從未包括index.htmlinline template。總是加載nothing here but this text。我在這裏看到了很多問題,但沒有幫助。我錯過了什麼,這是特定於Django?

回答

1

我會說,這些線應該使它:

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

檢查工作plunker here

同時檢查:

+1

是固定的吧.. – 2014-09-22 18:42:18

+1

太好了,享受真棒UI路由器:) – 2014-09-22 18:53:56