Last active
December 20, 2015 11:59
-
-
Save boneskull/6127098 to your computer and use it in GitHub Desktop.
Potentially useless and harmful example of coercing a jQuery $.Deferred out of AngularJS' $q. See http://jsfiddle.net/boneskull/TX7fA/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var myApp = angular.module('myApp', []); | |
$(function () { | |
var body = $('body'), | |
injector = body.injector(), | |
giveMeJQueryPromise = function ($log, $timeout) { | |
var dfrd = $.Deferred(); | |
$log.log('deferring'); | |
$timeout(angular.noop, 2000).then(function () { | |
dfrd.resolve('deferred'); | |
}); | |
return dfrd.promise(); | |
}; | |
jqpromise = injector.invoke(giveMeJQueryPromise); | |
jqpromise.then(function (res) { | |
console.log(res); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment