mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-23 19:40:56 +08:00
docs(ngMock): fix example for $http respond() helper with function as 1st param
The `whenPOST` method should return a response object containing status, response body and headers. If omitted the following error will be thrown: `Uncaught TypeError: Cannot read property '2' of undefined` The documentation doesn't make it very clear, so I think it will be appropriate to add it here. Closes #6761
This commit is contained in:
committed by
Caitlin Potter
parent
e1f1d65d0c
commit
1f1cad8517
4
src/ngMock/angular-mocks.js
vendored
4
src/ngMock/angular-mocks.js
vendored
@@ -1793,7 +1793,9 @@ angular.module('ngMockE2E', ['ng']).config(['$provide', function($provide) {
|
||||
*
|
||||
* // adds a new phone to the phones array
|
||||
* $httpBackend.whenPOST('/phones').respond(function(method, url, data) {
|
||||
* phones.push(angular.fromJson(data));
|
||||
* var phone = angular.fromJson(data);
|
||||
* phones.push(phone);
|
||||
* return [200, phone, {}];
|
||||
* });
|
||||
* $httpBackend.whenGET(/^\/templates\//).passThrough();
|
||||
* //...
|
||||
|
||||
Reference in New Issue
Block a user