angular.module('telavox.test', []) .factory('MySimulatedSlowHTTPService', function($q, $timeout) { var deferred = $q.defer(); $timeout(function() { // Simulated slow fetch from an HTTP server deferred.resolve(['Item 1', 'Item 2', 'Item 3']) }, 3000); return deferred.promise; }) .controller('MyTestController', function($scope, MySimulatedSlowHTTPService) { $scope.mylist = MySimulatedSlowHTTPService; });
<div ng-app="telavox.test"> <div data-ng-controller="MyTestController"> <p data-ng-repeat="item in mylist" data-ng-bind="item"> </p> </div> </div>
</style> <!-- Ugly Hack due to jsFiddle issue: http://goo.gl/BUfGZ --> <link rel="stylesheet" href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css"> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.6/angular.min.js"></script> <style>