@@ -53,8 +53,10 @@ angular.module('ionic.service.popup', ['ionic.service.templateLoad'])
53
53
console.log('Tapped!', res);
54
54
}, function(err) {
55
55
console.log('Err:', err);
56
- }, function(msg) {
57
- console.log('message:', msg);
56
+ }, function(popup) {
57
+ // If you need to access the popup directly, do it in the notify method
58
+ // This is also where you can programatically close the popup:
59
+ // popup.close();
58
60
});
59
61
60
62
// A confirm dialog
@@ -252,7 +254,10 @@ angular.module('ionic.service.popup', ['ionic.service.templateLoad'])
252
254
var constructPopupOnScope = function ( element , scope ) {
253
255
var popup = {
254
256
el : element [ 0 ] ,
255
- scope : scope
257
+ scope : scope ,
258
+ close : function ( ) {
259
+ popAndRemove ( this ) ;
260
+ }
256
261
} ;
257
262
258
263
scope . popup = popup ;
@@ -318,13 +323,20 @@ angular.module('ionic.service.popup', ['ionic.service.templateLoad'])
318
323
} ;
319
324
320
325
326
+
321
327
// Public API
322
328
return {
329
+ /**
330
+ * @private
331
+ */
323
332
showPopup : function ( data ) {
324
333
var q = $q . defer ( ) ;
325
334
326
335
createPopup ( data , q ) . then ( function ( popup , scope ) {
327
336
337
+ // Send the popup back
338
+ q . notify ( popup ) ;
339
+
328
340
// We constructed the popup, push it on the stack and show it
329
341
pushAndShow ( popup , data ) ;
330
342
@@ -340,7 +352,8 @@ angular.module('ionic.service.popup', ['ionic.service.templateLoad'])
340
352
* @name $ionicPopup#show
341
353
* @description show a complex popup. This is the master show function for all popups
342
354
* @param {data } object The options for showing a popup, of the form:
343
- *
355
+ * @returns {Promise } an Angular promise which resolves when the user enters the correct data, and also
356
+ * sends the constructed popup in the notify function (for programatic closing, as shown in the example above).
344
357
* ```
345
358
* {
346
359
* content: '', // String. The content of the popup
0 commit comments