标签:
用来实现基本的RESTful风格的API.
后端用django rest_framework(DRF),前端用AngularJS。
app.js
var prismVersion = angular.module("prismVersion", [‘ngResource‘]);
services.js
prismVersion.factory("versionSrv", [‘$resource‘, function ($resource) {
return $resource(
"http://127.0.0.1:8000/server_api/version_api/:Id",
{Id: "@Id" },
{‘query‘: {method: ‘GET‘ }},
{update: {method: "PUT"}}
);
}]);
controllers.js
prismVersion.controller(‘versionCtrl‘,[‘$scope‘,‘versionSrv‘,function($scope, versionSrv){ $scope.versions = versionSrv.query(); }]);
demo.html
<body ng-app="prismVersion"> <div >Header</div> <div ng-controller="versionCtrl"> {{versions}} hello </div> <div >Footer</div> </body>

标签:
原文地址:http://www.cnblogs.com/aguncn/p/5761454.html