diff --git a/js/ext/angular/src/directive/ionicScroll.js b/js/ext/angular/src/directive/ionicScroll.js
index dd45ff34db..a946019a2f 100644
--- a/js/ext/angular/src/directive/ionicScroll.js
+++ b/js/ext/angular/src/directive/ionicScroll.js
@@ -23,18 +23,10 @@ angular.module('ionic.ui.scroll', [])
* @param {boolean=} scrollbar-x Whether to show the horizontal scrollbar. Default false.
* @param {boolean=} scrollbar-x Whether to show the vertical scrollbar. Default true.
*/
-.directive('ionScroll', ['$parse', '$timeout', '$controller', function($parse, $timeout, $controller) {
+.directive('ionScroll', ['$parse', '$timeout', '$controller', '$ionicBind', function($parse, $timeout, $controller, $ionicBind) {
return {
restrict: 'E',
- scope: {
- direction: '@',
- paging: '@',
- onRefresh: '&',
- onScroll: '&',
- scroll: '@',
- scrollbarX: '@',
- scrollbarY: '@',
- },
+ scope: true,
controller: function() {},
compile: function(element, attr) {
element.addClass('scroll-view');
@@ -48,6 +40,15 @@ angular.module('ionic.ui.scroll', [])
function prelink($scope, $element, $attr) {
var scrollView, scrollCtrl;
+ $ionicBind($scope, $attr, {
+ direction: '@',
+ paging: '@',
+ $onScroll: '&onScroll',
+ scroll: '@',
+ scrollbarX: '@',
+ scrollbarY: '@',
+ });
+
if (angular.isDefined($attr.padding)) {
$scope.$watch($attr.padding, function(newVal) {
innerElement.toggleClass('padding', !!newVal);
diff --git a/js/ext/angular/test/directive/ionicContent.unit.js b/js/ext/angular/test/directive/ionicContent.unit.js
index 329c0b45f4..a305e60256 100644
--- a/js/ext/angular/test/directive/ionicContent.unit.js
+++ b/js/ext/angular/test/directive/ionicContent.unit.js
@@ -21,6 +21,18 @@ describe('Ionic Content directive', function() {
expect(element.hasClass('scroll-content')).toBe(true);
});
+ it('has $onScroll (used by $ionicScrollController)', function() {
+ element = compile('')(scope);
+ scope = element.scope();
+ scope.foo = jasmine.createSpy('foo');
+ scope.$apply();
+ expect(typeof scope.$onScroll).toBe('function');
+
+ expect(scope.foo).not.toHaveBeenCalled();
+ scope.$onScroll();
+ expect(scope.foo).toHaveBeenCalled();
+ });
+
it('should add padding classname', function() {
var element = compile('')(scope);
var scrollElement = element.find('.scroll');
diff --git a/js/ext/angular/test/directive/ionicScroll.unit.js b/js/ext/angular/test/directive/ionicScroll.unit.js
index a482ec7259..d235432b6c 100644
--- a/js/ext/angular/test/directive/ionicScroll.unit.js
+++ b/js/ext/angular/test/directive/ionicScroll.unit.js
@@ -19,6 +19,18 @@ describe('Ionic Scroll Directive', function() {
expect(element.controller('$ionicScroll').element).toBe(element[0]);
});
+ it('has $onScroll (used by $ionicScrollController)', function() {
+ element = compile('')(scope);
+ scope = element.scope();
+ scope.foo = jasmine.createSpy('foo');
+ scope.$apply();
+ expect(typeof scope.$onScroll).toBe('function');
+
+ expect(scope.foo).not.toHaveBeenCalled();
+ scope.$onScroll();
+ expect(scope.foo).toHaveBeenCalled();
+ });
+
it('Has scroll-view class', function() {
element = compile('')(scope);
expect(element.hasClass('scroll-view')).toBe(true);