Skip to content

Instantly share code, notes, and snippets.

@Colorfulstan
Created September 8, 2016 11:26
Show Gist options
  • Save Colorfulstan/5950c78b6daa2ac1e18b261f2ca6e7c9 to your computer and use it in GitHub Desktop.
Save Colorfulstan/5950c78b6daa2ac1e18b261f2ca6e7c9 to your computer and use it in GitHub Desktop.
function enablePromises(app) {
app.run(["$rootScope",function ($rootScope) {
Promise.setScheduler(function (cb) {
$rootScope.$evalAsync(cb);
});
}]);
}
var app = angular.module('HelloApp', []);
enablePromises(app);
app.controller("HomeController", function ($scope) {
var p = Promise.delay(1000).then(function () {
$scope.name = "Bluebird!";
console.log("Here!", $scope.name);
}).then(function () {
$scope.also = "Promises";
});
$scope.name = "$q";
$scope.also = "promises";
});
window.app = app;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment