mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
refactor($ionicScrollDelegate): make it a factory from current scope
BREAKING CHANGE: $ionicScrollDelegate no longer works globally; you must
create a new instance of each time you use it. The actual methods on
each instance of $ionicScrollDelegate are the same, however.
Change your code from this:
```js
function MyController($scope, $ionicScrollDelegate) {
$scope.scrollTop = function() {
$ionicScrollDelegate.scrollTop();
};
}
```
To this:
```js
function MyController($scope, $ionicScrollDelegate) {
var delegate = $ionicScrollDelegate($scope);
$scope.scrollTop = function() {
delegate.scrollTop();
};
}
```
This commit is contained in:
@@ -22,6 +22,17 @@ describe('$ionicScroll Controller', function() {
|
||||
});
|
||||
}
|
||||
|
||||
it('should set this.$scope', function() {
|
||||
setup();
|
||||
//Just an arbitrary way of checking that it is indeed a scope
|
||||
expect(typeof ctrl.$scope.$id).toBe('string');
|
||||
});
|
||||
|
||||
it('should set $scope.$$ionicScrollController', function() {
|
||||
setup();
|
||||
expect(ctrl.$scope.$$ionicScrollController).toBe(ctrl);
|
||||
});
|
||||
|
||||
it('should set this.element and this.$element', function() {
|
||||
setup();
|
||||
expect(ctrl.element.tagName).toMatch(/div/i);
|
||||
|
||||
Reference in New Issue
Block a user