mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-07 15:07:13 +08:00
Refresh and refresh callback on content directive
This commit is contained in:
7
js/ext/angular/src/directive/ionicContent.js
vendored
7
js/ext/angular/src/directive/ionicContent.js
vendored
@ -20,6 +20,7 @@ angular.module('ionic.ui.content', [])
|
||||
replace: true,
|
||||
template: '<div class="scroll-content"><div class="scroll"></div></div>',
|
||||
transclude: true,
|
||||
scope: true,
|
||||
compile: function(element, attr, transclude) {
|
||||
return function($scope, $element, $attr) {
|
||||
var c = $element.eq(0);
|
||||
@ -45,7 +46,10 @@ angular.module('ionic.ui.content', [])
|
||||
} else {
|
||||
// Otherwise, supercharge this baby!
|
||||
var sv = new ionic.views.Scroll({
|
||||
el: $element[0].firstElementChild
|
||||
el: $element[0].firstElementChild,
|
||||
onRefresh: function() {
|
||||
$scope.onRefresh && $scope.onRefresh();
|
||||
}
|
||||
});
|
||||
// Let child scopes access this
|
||||
$scope.scrollView = sv;
|
||||
@ -63,7 +67,6 @@ angular.module('ionic.ui.content', [])
|
||||
restrict: 'E',
|
||||
replace: true,
|
||||
transclude: true,
|
||||
scope: true,
|
||||
template: '<div class="scroll-refresher"><div class="scroll-refresher-content" ng-transclude></div></div>'
|
||||
}
|
||||
})
|
||||
|
||||
@ -42,7 +42,10 @@
|
||||
#refresh-content {
|
||||
color: #999;
|
||||
text-align: center;
|
||||
font-size: 20px;
|
||||
font-size: 48px;
|
||||
position: absolute;
|
||||
bottom: 10px;
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
|
||||
@ -52,9 +55,11 @@
|
||||
<header class="bar bar-header bar-success">
|
||||
<button class="button"><i class="icon ion-home"></i></button>
|
||||
</header>
|
||||
<content has-header="true" ng-controller="AppCtrl" class="reveal-animation">
|
||||
<content on-refresh="onRefresh()" has-header="true" ng-controller="AppCtrl" class="reveal-animation">
|
||||
<refresher>
|
||||
Refreshing
|
||||
<div id="refresh-content">
|
||||
<i class="icon ion-ios7-reloading"></i>
|
||||
</div>
|
||||
</refresher>
|
||||
<ul class="list">
|
||||
<li class="list-item" ng-repeat="item in items">asdf{{$index}}</li>
|
||||
@ -73,6 +78,9 @@
|
||||
});
|
||||
}
|
||||
$scope.what = {};
|
||||
$scope.onRefresh = function() {
|
||||
console.log('On refresh');
|
||||
}
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user