自己用angualrjs 写的前台,然后django写的后台,怎么让两个组合起来。 angularjs中有主页面和模板,django里面也有。 输入一个url,django获取url返回的是什么呢,是全部模板和页面,js,css都返回吗,
Angular only requests the page from the background during the first request. Subsequent requests request background data to update the page by calling the background API.
Use Django to build RESTful API
You can refer to this my blog: phodaldev
As follows
{% block main %} <script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.16/angular.min.js"></script> <script type="text/javascript"> var blogposts = angular.module('blogposts',[]); blogposts.config(function($interpolateProvider) { $interpolateProvider.startSymbol('{[{'); $interpolateProvider.endSymbol('}]}'); }); blogposts.controller('blogController', function($scope, $http) { $http.get('/api/v1/url/?limit=600&format=json').success(function(data) { $scope.posts = data["objects"]; }); }); </script> <p ng-app="blogposts"> <p class="posts" ng-controller="blogController"> <ul> <li ng-repeat="post in posts"><a href="/blog/{[{post.slug}]}">{[{post.title}]}</a></li> </ul> </p> </p> {% endblock %}
Angular only requests the page from the background during the first request. Subsequent requests request background data to update the page by calling the background API.
Use Django to build RESTful API
You can refer to this my blog: phodaldev
As follows