Suziemac Tani
Suziemac Tani

Reputation: 455

Angular-ui-router not rendering templates with django

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

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

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.

and in index.html which inherits base.html

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

my 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?

Upvotes: 2

Views: 1080

Answers (1)

Radim K&#246;hler
Radim K&#246;hler

Reputation: 123901

I would say that these lines should make it:

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

Check the working plunker here

Also check:

Upvotes: 1

Related Questions