docs($httpBackend): add module declaration for best understanding

According with the Issue #9537. This module declaration in the test is very important. When I started to test in angular I copy and paste this code to see how it works, and I get this `module undefined error`, and just after read some blog posts I figure out that this line is essential for testing your module. So, for best understanding of begginers this can be very helpful.

Closes #9563
This commit is contained in:
Lucas N. Munhoz
2014-10-10 16:38:50 -03:00
committed by Igor Minar
parent 3345bf8bc7
commit 0f6aa10413

View File

@@ -994,6 +994,11 @@ angular.mock.dump = function(object) {
* First we create the controller under test:
*
```js
// The module code
angular
.module('MyApp', [])
.controller('MyController', MyController);
// The controller code
function MyController($scope, $http) {
var authToken;
@@ -1023,6 +1028,9 @@ angular.mock.dump = function(object) {
describe('MyController', function() {
var $httpBackend, $rootScope, createController, authRequestHandler;
// Set up the module
beforeEach(module('MyApp'));
beforeEach(inject(function($injector) {
// Set up the mock http service responses
$httpBackend = $injector.get('$httpBackend');