If you want to mock your backend during development, just install angular-mocks
in your main html file, add it up as a dependency in your application (angular.module('myApp', ['ngMockE2E'])
) and then mock the requests you need to.
E.g.
angular.module('myApp')
.controller('MainCtrl', function ($scope, $httpBackend, $http) {
$httpBackend.whenGET('test').respond(200, {message: "Hello world"});
$http.get('test').then(function(response){
$scope.message = response.message //Hello world
})
});
Be wary though, that adding the ngMockE2E
will require you to set up your routes in case you do so through AngularJS routing.
E.g.
angular.module('myApp', ['ngMockE2E'])
.config(function ($routeProvider) {
$routeProvider
.when('/', {
templateUrl: 'views/main.html',
controller: 'MainCtrl'
})
.otherwise({
redirectTo: '/'
});
})
.run(function($httpBackend){
$httpBackend.whenGET('views/main.html').passThrough();
})