【发布时间】:2012-12-30 12:14:21
【问题描述】:
假设我的 Angular 应用程序周围有几个 $resources 和一些 $http:
myApp.factory('Note', function($resource) {
return $resource('http://', {id: '@id'},
{ 'index': { method: 'GET', isArray: true },
'update': { method: 'PUT'},
});
});
带控制器
myApp.controller('NotesController',function NotesController($scope, Note, AuthenticationService) {
$scope.notes = Note.index({}, function(data){
console.log('success, got data: ', data);
$scope.response = "yoy!"
}, function(err){
console.log('error, got data: ', err);
$scope.response = "yay!"
});
});
有些请求是由 $http 直接发出的,例如身份验证
var request = $http.post('http://', {email: email, password: password});
在发出实际请求/接收响应之前,我可以在哪里以及如何告诉 Angular 将 JSON 压缩和编码/解码为 base64?
我想我将包装外部库以用于放气和编码/解码到工厂。然后这个工厂会被注入到这里? 喜欢 $httpBackend 吗?
【问题讨论】:
标签: json http base64 angularjs deflate