2014-03-04 6 views
0

저는 장고를 통해 기본 angularjs 웹 페이지를 작성하려고합니다. (이 예제에서는 django를 실제로 사용하지 않습니다). 예제를 정확히 복사하려했지만 작동하지 않습니다. 부분 및 컨트롤러가로드되지 않습니다. URL이 업데이트되어 앱이로드되고 있음을 알 수 있습니다. 그러나 부분적으로나 데이터 적으로는 웹 서버에 전혀 영향을 미치지 않습니다. 도움을 주시면 감사하겠습니다.angularjs가 부분적으로로드되지 않습니다.

다음은 내가 작성할 수있는 가장 간단한 코드입니다.

인 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/TemplateUrl되어야

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; 
      }); 
     }]); 
+0

JS 콘솔에서 모든 오류 출력? – balteo

답변

6

TemplateURL을 app.js. 또한, 당신은 당신의 templateUrl 경로에서 첫 번째 슬래시를 제거하고 그 차이가 있는지 확인하기 위해 시도 할 수 있습니다 : 그래서 :

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

이된다 :

templateUrl: 'static/partials/question-list.html', 
+0

예. URL이 아닌 URL. 나는 그것이 단순해야만한다는 것을 알았다. 너무 가까이 !! – AlexH

+0

나는 소문자로 이것을 가지고 있었다. :) – Haring10

관련 문제