diff --git a/js/ext/angular/src/directive/ionicList.js b/js/ext/angular/src/directive/ionicList.js index 9c83f1e908..ddcb126a5e 100644 --- a/js/ext/angular/src/directive/ionicList.js +++ b/js/ext/angular/src/directive/ionicList.js @@ -104,11 +104,11 @@ angular.module('ionic.ui.list', ['ngAnimate']) $scope.deleteClick = function() { if($attr.onDelete) { // this item has an on-delete attribute - $scope.onDelete({ item: $scope.item }); + $scope.onDelete({ item: $scope.item, index: $scope.$parent.$index }); } else if($parentAttrs.onDelete) { // run the parent list's onDelete method // if it doesn't exist nothing will happen - $parentScope.onDelete({ item: $scope.item }); + $parentScope.onDelete({ item: $scope.item, index: $scope.$parent.$index }); } }; diff --git a/js/ext/angular/src/service/ionicPopup.js b/js/ext/angular/src/service/ionicPopup.js index 634ea66be3..21b25855b5 100644 --- a/js/ext/angular/src/service/ionicPopup.js +++ b/js/ext/angular/src/service/ionicPopup.js @@ -53,8 +53,10 @@ angular.module('ionic.service.popup', ['ionic.service.templateLoad']) console.log('Tapped!', res); }, function(err) { console.log('Err:', err); - }, function(msg) { - console.log('message:', msg); + }, function(popup) { + // If you need to access the popup directly, do it in the notify method + // This is also where you can programatically close the popup: + // popup.close(); }); // A confirm dialog @@ -252,7 +254,10 @@ angular.module('ionic.service.popup', ['ionic.service.templateLoad']) var constructPopupOnScope = function(element, scope) { var popup = { el: element[0], - scope: scope + scope: scope, + close: function() { + popAndRemove(this); + } }; scope.popup = popup; @@ -318,13 +323,20 @@ angular.module('ionic.service.popup', ['ionic.service.templateLoad']) }; + // Public API return { + /** + * @private + */ showPopup: function(data) { var q = $q.defer(); createPopup(data, q).then(function(popup, scope) { + // Send the popup back + q.notify(popup); + // We constructed the popup, push it on the stack and show it pushAndShow(popup, data); @@ -340,7 +352,8 @@ angular.module('ionic.service.popup', ['ionic.service.templateLoad']) * @name $ionicPopup#show * @description show a complex popup. This is the master show function for all popups * @param {data} object The options for showing a popup, of the form: - * + * @returns {Promise} an Angular promise which resolves when the user enters the correct data, and also + * sends the constructed popup in the notify function (for programatic closing, as shown in the example above). * ``` * { * content: '', // String. The content of the popup diff --git a/js/ext/angular/test/list.html b/js/ext/angular/test/list.html index 606072cdf8..b5479c3449 100644 --- a/js/ext/angular/test/list.html +++ b/js/ext/angular/test/list.html @@ -102,7 +102,7 @@ on-refresh="refreshItems()" on-reorder="onReorder(el, start, end)" refresh-complete="refreshComplete" - on-delete="deleteListItem(item)" + on-delete="deleteListItem(item, index)" delete-icon="ion-minus-circled" reorder-icon="ion-navicon" animation="my-repeat-animation" @@ -112,7 +112,7 @@ option-buttons="optionButtons1"> - +

{{item.from}}

{{item.text}}

@@ -134,7 +134,7 @@
- - - - - - + + + + + + +
+