angular-promiseify

1.0.0 • Public • Published

angular-promiseify

NPM version

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
    });
    
});

LICENSE

MIT License

Readme

Keywords

Package Sidebar

Install

npm i angular-promiseify

Weekly Downloads

3

Version

1.0.0

License

MIT

Last publish

Collaborators

  • howard.zuo