Just use a service/factory... Later on, you can swap $q for $http and call some RESTful backend...
You can also use $httpBackend<http://docs.angularjs.org/api/ngMockE2E.$httpBackend>, but I find that is more work at the onset... angular.module('app') .factory('FooService', ['$q', function($q) { return { getFoo: function() { deferred = $q.defer(); deferred.resolve({ "bar": "baz" }); return deferred.promise; } }; }]) .controller('MyController', ['$scope', 'FooService', function($scope, fooService) { $scope.myBar = fooService.getFoo(); }]); On Wednesday, February 12, 2014 10:31:31 AM UTC-5, gitted wrote: > > Say you want to start a new project, but you want a fully working website > without having to do all the backend server side coding. > > How could you do this with Angularjs? Is it possible to route all > requests to a mock backend which is just sample json responses? > > This way, you can see how the website will work exactly like in production > w/o having to write the database layer and backend serverices etc. > -- You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/angular. For more options, visit https://groups.google.com/groups/opt_out.
