angular-promiseify
v1.0.0
Published
Turn regular callback-based function into $q promise
Downloads
7
Readme
angular-promiseify
Turn regular callback-based function into $q promise
Installation
From bower
bower install angular-promiseify
From npm
npm install angular-promiseify
Usage
<script type="text/javascript" src="node_modules/angular/angular.min.js"></script>
<script type="text/javascript" src="node_modules/angular-promiseify/angular-promiseify.min.js"></script>
'use strict';
var mod = angular.module('demo', ['angular-promiseify']);
mod.controller('TestCtrl', function($scope, promiseify){
var testFunc = function(arg1, arg2, callback){
$timeout(function(){
callback('ok');
}, 300);
};
var test = promiseify(testFunc);
test('a', 'b')
.then(function(data){
console.log(data);//here "ok" will be printed
});
});