fix(ionReorderButton): fix onReorder not triggering angular digest

This commit is contained in:
Andrew Joslin
2014-05-20 08:58:26 -06:00
parent 4d793fd9f4
commit cc46735c82
3 changed files with 18 additions and 12 deletions

View File

@@ -250,7 +250,12 @@ function($animate, $timeout) {
onReorder: function(el, oldIndex, newIndex) {
var itemScope = jqLite(el).scope();
if (itemScope && itemScope.$onReorder) {
itemScope.$onReorder(oldIndex, newIndex);
//Make sure onReorder is called in apply cycle,
//but also make sure it has no conflicts by doing
//$evalAsync
itemScope.$evalAsync(function() {
itemScope.$onReorder(oldIndex, newIndex);
});
}
},
canSwipe: function() {

View File

@@ -9,19 +9,18 @@
<ion-tab title="So Tabular!">
<div ng-if="$root.headerExists">
<ion-header-bar class="bar-positive"
ng-class="{'bar-subheader': $root.isSubheader}">
<h1 class="title">Header Bar</h1>
</ion-header-bar>
<ion-header-bar ng-show="$root.headerExists"
class="bar-positive"
ng-class="{'bar-subheader': $root.isSubheader}">
<h1 class="title">Header Bar</h1>
</ion-header-bar>
</div>
<div ng-if="$root.footerExists">
<ion-footer-bar class="bar-assertive"
ng-class="{'bar-subfooter': $root.isSubfooter}">
<h1 class="title">Footer bar</h1>
</ion-footer-bar>
</div>
<ion-footer-bar ng-show="$root.footerExists"
class="bar-assertive"
ng-class="{'bar-subfooter': $root.isSubfooter}">
<h1 class="title">Footer bar</h1>
</ion-footer-bar>
<ion-content>
<div class="card">

View File

@@ -110,6 +110,8 @@ describe('ionList directive', function() {
el.scope().$onReorder = jasmine.createSpy('$onReorder');
options.onReorder(el, 2, 3);
expect(el.scope().$onReorder).not.toHaveBeenCalled();
el.scope().$apply();
expect(el.scope().$onReorder).toHaveBeenCalledWith(2,3);
});