Skip to content

Instantly share code, notes, and snippets.

@ayeo
Last active December 31, 2015 04:39
Show Gist options
  • Save ayeo/7936126 to your computer and use it in GitHub Desktop.
Save ayeo/7936126 to your computer and use it in GitHub Desktop.
angular.module('myModule', ['ngRoute'])
.factory('MessageResolver', ['$q', '$timeout', function($q, $timeout)
{
var deferred = $q.defer();
$timeout(function()
{
deferred.resolve(['Hello', 'world!']);
}, 2000);
return deferred.promise;
}])
.controller('HelloCtrl', ['$scope', 'MessageResolver', function($scope, MessageResolver)
{
MessageResolver.then(function(messages)
{
$scope.messages = messages;
})
}])
.config(['$routeProvider', function($routeProvider)
{
$routeProvider.when('/',
{
templateUrl: 'index2.html',
controller: "HelloCtrl",
});
}])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment