mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
fix(ionReorderButton): fix onReorder not triggering angular digest
This commit is contained in:
7
js/angular/directive/list.js
vendored
7
js/angular/directive/list.js
vendored
@@ -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() {
|
||||
|
||||
@@ -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">
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user