Created
November 15, 2013 23:07
-
-
Save kennethlynne/7493225 to your computer and use it in GitHub Desktop.
Mock back-end for angular for prototyping
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('APP') | |
.config(function($provide) { | |
//Decorate backend with awesomesauce | |
$provide.decorator('$httpBackend', angular.mock.e2e.$httpBackendDecorator); | |
}) | |
.run(function ($httpBackend) { | |
//Pass trough views | |
var viewsDir = 'views/'; | |
var viewsDirRegex = new RegExp(viewsDir.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&")); | |
$httpBackend.whenGET(viewsDirRegex).passThrough(); | |
$httpBackend.whenGET('/Users').respond(function(method, url, data, headers) { | |
return [200, GenerateMockUsers(), {/*headers*/}]; | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment