Skip to content
This repository was archived by the owner on Sep 15, 2021. It is now read-only.

Commit ef452ed

Browse files
committed
fix(plugin:printer): fix isAvailable function + promise for print function
1 parent 01319b8 commit ef452ed

File tree

5 files changed

+27
-15
lines changed

5 files changed

+27
-15
lines changed

demo/www/lib/ngCordova/ng-cordova.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,7 +1023,7 @@ angular.module('ngCordova.plugins.contacts', [])
10231023

10241024
clone: function (contact) {
10251025
var deviceContact = navigator.contacts.create(contact);
1026-
return deviceContact.clone(contact)
1026+
return deviceContact.clone(contact);
10271027
},
10281028

10291029
find: function (options) {
@@ -1063,7 +1063,7 @@ angular.module('ngCordova.plugins.contacts', [])
10631063
// TODO: method to set / get ContactName
10641064
// TODO: method to set / get ContactOrganization
10651065

1066-
}
1066+
};
10671067

10681068
}]);
10691069

@@ -3050,15 +3050,19 @@ angular.module('ngCordova.plugins.printer', [])
30503050
isAvailable: function () {
30513051
var q = $q.defer();
30523052

3053-
$window.plugin.printer.isServiceAvailable(function (isAvailable) {
3053+
$window.plugin.printer.isAvailable(function (isAvailable) {
30543054
q.resolve(isAvailable);
30553055
});
30563056

30573057
return q.promise;
30583058
},
30593059

3060-
print: function (doc) {
3061-
$window.plugin.printer.print(doc);
3060+
print: function (doc, options) {
3061+
var q = $q.defer();
3062+
$window.plugin.printer.print(doc, options, function () {
3063+
q.resolve();
3064+
});
3065+
return q.promise;
30623066
}
30633067
}
30643068
}

demo/www/lib/ngCordova/ng-cordova.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/ng-cordova.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,7 +1023,7 @@ angular.module('ngCordova.plugins.contacts', [])
10231023

10241024
clone: function (contact) {
10251025
var deviceContact = navigator.contacts.create(contact);
1026-
return deviceContact.clone(contact)
1026+
return deviceContact.clone(contact);
10271027
},
10281028

10291029
find: function (options) {
@@ -1063,7 +1063,7 @@ angular.module('ngCordova.plugins.contacts', [])
10631063
// TODO: method to set / get ContactName
10641064
// TODO: method to set / get ContactOrganization
10651065

1066-
}
1066+
};
10671067

10681068
}]);
10691069

@@ -3050,15 +3050,19 @@ angular.module('ngCordova.plugins.printer', [])
30503050
isAvailable: function () {
30513051
var q = $q.defer();
30523052

3053-
$window.plugin.printer.isServiceAvailable(function (isAvailable) {
3053+
$window.plugin.printer.isAvailable(function (isAvailable) {
30543054
q.resolve(isAvailable);
30553055
});
30563056

30573057
return q.promise;
30583058
},
30593059

3060-
print: function (doc) {
3061-
$window.plugin.printer.print(doc);
3060+
print: function (doc, options) {
3061+
var q = $q.defer();
3062+
$window.plugin.printer.print(doc, options, function () {
3063+
q.resolve();
3064+
});
3065+
return q.promise;
30623066
}
30633067
}
30643068
}

dist/ng-cordova.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/plugins/printer.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,19 @@ angular.module('ngCordova.plugins.printer', [])
99
isAvailable: function () {
1010
var q = $q.defer();
1111

12-
$window.plugin.printer.isServiceAvailable(function (isAvailable) {
12+
$window.plugin.printer.isAvailable(function (isAvailable) {
1313
q.resolve(isAvailable);
1414
});
1515

1616
return q.promise;
1717
},
1818

19-
print: function (doc) {
20-
$window.plugin.printer.print(doc);
19+
print: function (doc, options) {
20+
var q = $q.defer();
21+
$window.plugin.printer.print(doc, options, function () {
22+
q.resolve();
23+
});
24+
return q.promise;
2125
}
2226
}
2327
}

0 commit comments

Comments
 (0)