1

When running yeoman server I want to be able to create URL stubs to simulate backend responses.

Take for example the following controller:

angularApp.controller('AppuserListCtrl', function ($scope, $http) {

        $http({method: 'GET', url: '/admin/appuser/rest/?accept=json'})
        .success(function (data, status, headers, config) {
            $scope.page = data;
        })
        .error(function (data, status, headers, config) {
            $scope.error = data;
        });
});

This controller depends on an ajax request to retrieve a json object to do any work. Is there a way to stub those out with yeoman server ?

javito
  • 1,529
  • 6
  • 16
  • 24

1 Answers1

0

You can use $httpBackend to mock the $http object.

Luis
  • 1
  • 2
  • 1
    I'm talking about production code, not tests. What I opted for is CORS on the server side so I could use ajax requests with the actual backend. AFAIK there's no other way to develop with yeoman when using server side requests. – javito Feb 26 '13 at 11:24