Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

$http service #609

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
31925e7
feat($browser): xhr returns raw request object
vojtajina Aug 3, 2011
42a2548
fix($browser.xhr): change method "JSON" to "JSONP"
vojtajina Aug 10, 2011
d05bd63
fix($browser.xhr): respond with internal -2 status on jsonp error
vojtajina Aug 10, 2011
c240ab6
fix($browser.xhr): fix IE6, IE7 bug - sync xhr when serving from cache
vojtajina Aug 18, 2011
d0c3c43
feat($browser.xhr): add timeout option to abort request
vojtajina Aug 18, 2011
15dea1e
feat($cacheFactory): add general purpose $cacheFactory service
IgorMinar Feb 17, 2011
343d25f
feat($http): new $http service, removing $xhr.*
vojtajina Aug 4, 2011
6993a40
feat(mocks.$httpBackend): add $httpBackend mock
vojtajina Aug 16, 2011
ce73a50
feat($templateCache): add $templateCache - shared by ng:include, ng:view
vojtajina Oct 18, 2011
9a7447e
feat(mocks.$browser): add simple addJs() method into $browser mock
vojtajina Aug 23, 2011
c19f2de
feat($httpBackend): extract $browser.xhr into separate service
vojtajina Aug 23, 2011
e02df36
feat($http): expose pendingRequests and configuration object
vojtajina Oct 18, 2011
821e6c7
fix($http): allow multiple json vulnerability prefixes
vojtajina Oct 19, 2011
5448f04
fix($resource): to work with $http, $httpBackend services
vojtajina Oct 19, 2011
a315a10
refactor($http): change callback matching mechanism
vojtajina Oct 27, 2011
85dba30
fix($http): add .send() alias for .retry() to get better stack trace …
vojtajina Oct 31, 2011
ceae30a
feat(mock.$httpBackend): throw when nothing to flush, dump data/heade…
vojtajina Oct 31, 2011
ba7bae4
feat($http): broadcast $http.request event
vojtajina Oct 31, 2011
f646f01
feat(mock.$httpBackend): add verifyNoOutstandingRequest method
vojtajina Nov 1, 2011
77d4c38
fix(mock.$httpBackend): flush() even requests sent during callbacks
vojtajina Nov 1, 2011
a7f13bf
refactor(mock.$httpBackend): rename when().then() to when().respond()
vojtajina Nov 1, 2011
033dac6
feat(mock.$httpBackend): verify expectations after flush()
vojtajina Nov 1, 2011
cff7b97
feat(mock.$httpBackend): say which request was expected when unexpect…
vojtajina Nov 3, 2011
e249231
feat($httpBackend): fix 0 status code when "file" protocol
vojtajina Nov 4, 2011
55cebd4
feat($http): allow passing custom cache instance per request
vojtajina Nov 4, 2011
0ef4d43
style(): get rid off some jsl warnings
vojtajina Nov 5, 2011
0144ede
fix($http): default json transformation should not crash on angular t…
vojtajina Nov 5, 2011
01b3677
refactor(ng:view, ng:include): pass cache instance into $http
vojtajina Nov 5, 2011
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions angularFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ angularFiles = {
'src/jqLite.js',
'src/apis.js',
'src/service/browser.js',
'src/service/cacheFactory.js',
'src/service/compiler.js',
'src/service/cookieStore.js',
'src/service/cookies.js',
Expand All @@ -30,10 +31,8 @@ angularFiles = {
'src/service/scope.js',
'src/service/sniffer.js',
'src/service/window.js',
'src/service/xhr.bulk.js',
'src/service/xhr.cache.js',
'src/service/xhr.error.js',
'src/service/xhr.js',
'src/service/http.js',
'src/service/httpBackend.js',
'src/service/locale.js',
'src/directives.js',
'src/markups.js',
Expand Down
4 changes: 2 additions & 2 deletions docs/content/cookbook/buzz.ngdoc
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ to retrieve Buzz activity and comments.
this.Activity = $resource(
'https://www.googleapis.com/buzz/v1/activities/:userId/:visibility/:activityId/:comments',
{alt: 'json', callback: 'JSON_CALLBACK'},
{ get: {method: 'JSON', params: {visibility: '@self'}},
replies: {method: 'JSON', params: {visibility: '@self', comments: '@comments'}}
{ get: {method: 'JSONP', params: {visibility: '@self'}},
replies: {method: 'JSONP', params: {visibility: '@self', comments: '@comments'}}
});
}
BuzzController.prototype = {
Expand Down
8 changes: 4 additions & 4 deletions src/AngularPublic.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ function ngModule($provide, $injector) {
});

$provide.service('$browser', $BrowserProvider);
$provide.service('$cacheFactory', $CacheFactoryProvider);
$provide.service('$compile', $CompileProvider);
$provide.service('$cookies', $CookiesProvider);
$provide.service('$cookieStore', $CookieStoreProvider);
Expand All @@ -75,6 +76,8 @@ function ngModule($provide, $injector) {
$provide.service('$exceptionHandler', $ExceptionHandlerProvider);
$provide.service('$filter', $FilterProvider);
$provide.service('$formFactory', $FormFactoryProvider);
$provide.service('$http', $HttpProvider);
$provide.service('$httpBackend', $HttpBackendProvider);
$provide.service('$location', $LocationProvider);
$provide.service('$log', $LogProvider);
$provide.service('$parse', $ParseProvider);
Expand All @@ -83,10 +86,7 @@ function ngModule($provide, $injector) {
$provide.service('$routeParams', $RouteParamsProvider);
$provide.service('$rootScope', $RootScopeProvider);
$provide.service('$sniffer', $SnifferProvider);
$provide.service('$templateCache', $TemplateCacheProvider);
$provide.service('$window', $WindowProvider);
$provide.service('$xhr.bulk', $XhrBulkProvider);
$provide.service('$xhr.cache', $XhrCacheProvider);
$provide.service('$xhr.error', $XhrErrorProvider);
$provide.service('$xhr', $XhrProvider);
}

21 changes: 11 additions & 10 deletions src/Resource.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ Route.prototype = {
}
};

function ResourceFactory(xhr) {
this.xhr = xhr;
function ResourceFactory($http) {
this.$http = $http;
}

ResourceFactory.DEFAULT_ACTIONS = {
Expand Down Expand Up @@ -107,11 +107,11 @@ ResourceFactory.prototype = {
}

var value = this instanceof Resource ? this : (action.isArray ? [] : new Resource(data));
self.xhr(
action.method,
route.url(extend({}, extractParams(data), action.params || {}, params)),
data,
function(status, response) {
var future = self.$http({
method: action.method,
url: route.url(extend({}, extractParams(data), action.params || {}, params)),
data: data
}).on('success', function(response, status) {
if (response) {
if (action.isArray) {
value.length = 0;
Expand All @@ -123,9 +123,10 @@ ResourceFactory.prototype = {
}
}
(success||noop)(value);
},
error || action.verifyCache,
action.verifyCache);
});

if (error) future.on('error', error);

return value;
};

Expand Down
Loading