Answer the question
In order to leave comments, you need to log in
How to use Django on the backend to make routing in AngularJS?
Good day.
Can you please tell me how to make client-side routing using Django + Angular?
In Angular's config I wrote the following:
.config(['$routeProvider', function($routeProvider) {
$routeProvider
.when('/', {
controller: 'MyCtrl',
templateUrl: 'views/main.html'
})
.when('/api/profile/:id', {
controller: 'TestController',
templateUrl: 'views/profile.html'
})
.otherwise({
redirectTo: '/'
})
<div ng-view></div>
GET http://localhost:8000/views/main.html 404 (NOT FOUND)
Error: [$compile:tpload] http://errors.angularjs.org/1.3.16/$compile/tpload?p0=views%2Fmain.html
at Error (native)
at http://localhost:8000/static/js/vendors/angular.min.js:6:417
at http://localhost:8000/static/js/vendors/angular.min.js:137:174
at http://localhost:8000/static/js/vendors/angular.min.js:112:182
at m.$get.m.$eval (http://localhost:8000/static/js/vendors/angular.min.js:126:250)
at m.$get.m.$digest (http://localhost:8000/static/js/vendors/angular.min.js:123:365)
at m.$get.m.$apply (http://localhost:8000/static/js/vendors/angular.min.js:127:12)
at l (http://localhost:8000/static/js/vendors/angular.min.js:81:327)
at P (http://localhost:8000/static/js/vendors/angular.min.js:85:449)
at XMLHttpRequest.H.onload (http://localhost:8000/static/js/vendors/angular.min.js:86:462)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question