0

I'm trying to put together a basic angularjs web page through django (but not really using django for this example). I tried to copy an example exactly, but it's not working. The partial and the controller are not loading. The url is updated, so I know the app is loading. But I don't see it hitting my web server at all for the partial or the data. Help would be appreciated.

Here is the simplest code I could put together.

test.html:

<!doctype html>
<html ng-app="ciqApp">
    <head>
        <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.14/angular.js"></script>
        <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.14/angular-route.js"></script>
        <script type="text/javascript" src="js/app.js"></script>
        <script type="text/javascript" src="js/controllers.js"></script>
    </head>
    <body>
        TEST
        <div ng-view>
        </div>
    </body>
</html>

js/app.js

var ciqApp = angular.module('ciqApp', [
        'ngRoute',
        'ciqControllers'
        ]);

ciqApp.config(['$routeProvider',
        function($routeProvider){
            $routeProvider.
                when('/questions', {
                    templateURL: '/static/partials/question-list.html',
                    controller: 'QuestionListCtrl'
                }).
                otherwise({
                    redirectTo: '/questions'
                });
        }]);

js/controllers.js

var ciqControllers = angular.module('ciqControllers', []);

ciqControllers.controller('QuestionListCtrl', ['$scope', '$http',
        function ($scope, $http) {
            $http.get('/get_questions').success(function(data) {
                $scope.questions = data;
            });
        }]);
1
  • Any error output from the js console? Commented Mar 4, 2014 at 21:39

1 Answer 1

6

TemplateURL should be TemplateUrl. Also, you can try to remove the first slash from your templateUrl path and see if that makes a difference: So:

templateURL: '/static/partials/question-list.html',

becomes:

templateUrl: 'static/partials/question-list.html',
Sign up to request clarification or add additional context in comments.

1 Comment

Yup. Url, not URL. I knew it had to be something simple. So close!!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.