I am setting up $httpBackend
to stub out fake API routes while our API developers are working on them. The problem is I have to put all my $httpBackend
definitions inside my run
block. As a result, my run
block will get quite large. I would like to know if there is a way to separate these out into different files, possibly using multiple run
blocks, or even some grunt task to compact them all into a single run
file.
You can actually create multiple run blocks in angular. Simply separate each run blocks into different files.
DEMO
A contrive example would look like this:
app.js
angular.module('app', ['ngMockE2E']);
mock.users.js
angular.module('app')
.run(function($httpBackend) {
// implement user api mock
});
mock.projects.js
angular.module('app')
.run(function($httpBackend) {
// implement project api mock
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With