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:
26
js/ext/angular/src/directive/ionicBar.js
vendored
26
js/ext/angular/src/directive/ionicBar.js
vendored
@@ -7,8 +7,7 @@ angular.module('ionic.ui.header', ['ngAnimate', 'ngSanitize'])
|
||||
return {
|
||||
restrict: 'C',
|
||||
link: function($scope, $element, $attr) {
|
||||
// We want to scroll to top when the top of this element is clicked
|
||||
$ionicScrollDelegate.tapScrollToTop($element);
|
||||
$ionicScrollDelegate($scope).tapScrollToTop($element);
|
||||
}
|
||||
};
|
||||
}])
|
||||
@@ -26,8 +25,9 @@ angular.module('ionic.ui.header', ['ngAnimate', 'ngSanitize'])
|
||||
* Is able to have left or right buttons, and additionally its title can be
|
||||
* aligned through the {@link ionic.controller:ionicBar ionicBar controller}.
|
||||
*
|
||||
* @param {string=} model The model to assign this headerBar's
|
||||
* {@link ionic.controller:ionicBar ionicBar controller} to.
|
||||
* @param {string=} type The type of the bar. For example 'bar-positive'.
|
||||
* @param {string=} model The model to assign this headerBar's
|
||||
* {@link ionic.controller:ionicBar ionicBar controller} to.
|
||||
* Defaults to assigning to $scope.headerBarController.
|
||||
* @param {string=} align-title Where to align the title at the start.
|
||||
* Avaialble: 'left', 'right', or 'center'. Defaults to 'center'.
|
||||
@@ -63,8 +63,9 @@ angular.module('ionic.ui.header', ['ngAnimate', 'ngSanitize'])
|
||||
* Is able to have left or right buttons, and additionally its title can be
|
||||
* aligned through the {@link ionic.controller:ionicBar ionicBar controller}.
|
||||
*
|
||||
* @param {string=} model The model to assign this footerBar's
|
||||
* {@link ionic.controller:ionicBar ionicBar controller} to.
|
||||
* @param {string=} type The type of the bar. For example 'bar-positive'.
|
||||
* @param {string=} model The model to assign this footerBar's
|
||||
* {@link ionic.controller:ionicBar ionicBar controller} to.
|
||||
* Defaults to assigning to $scope.footerBarController.
|
||||
* @param {string=} align-title Where to align the title at the start.
|
||||
* Avaialble: 'left', 'right', or 'center'. Defaults to 'center'.
|
||||
@@ -90,9 +91,9 @@ angular.module('ionic.ui.header', ['ngAnimate', 'ngSanitize'])
|
||||
function barDirective(isHeader) {
|
||||
var BAR_TEMPLATE = isHeader ?
|
||||
'<header class="bar bar-header" ng-transclude></header>' :
|
||||
'<footer class="bar bar-header" ng-transclude></footer>';
|
||||
var BAR_MODEL_DEFAULT = isHeader ?
|
||||
'headerBarController' :
|
||||
'<footer class="bar bar-footer" ng-transclude></footer>';
|
||||
var BAR_MODEL_DEFAULT = isHeader ?
|
||||
'headerBarController' :
|
||||
'footerBarController';
|
||||
return ['$parse', function($parse) {
|
||||
return {
|
||||
@@ -106,7 +107,12 @@ function barDirective(isHeader) {
|
||||
alignTitle: $attr.alignTitle || 'center'
|
||||
});
|
||||
|
||||
$parse($attr.model || BAR_MODEL_DEFAULT).assign($scope.$parent, hb);
|
||||
$parse($attr.model || BAR_MODEL_DEFAULT).assign($scope.$parent || $scope, hb);
|
||||
|
||||
$attr.$observe('type', function(val, oldVal) {
|
||||
oldVal && $element.removeClass(oldVal);
|
||||
$element.addClass(val);
|
||||
});
|
||||
}
|
||||
};
|
||||
}];
|
||||
|
||||
2
js/ext/angular/src/directive/ionicContent.js
vendored
2
js/ext/angular/src/directive/ionicContent.js
vendored
@@ -72,7 +72,7 @@ function($parse, $timeout, $ionicScrollDelegate, $controller, $ionicBind) {
|
||||
require: '^?ionNavView',
|
||||
scope: true,
|
||||
template:
|
||||
'<div class="scroll-content">' +
|
||||
'<div class="scroll-content" ng-class="$$contentState.getClassName()">' +
|
||||
'<div class="scroll"></div>' +
|
||||
'</div>',
|
||||
compile: function(element, attr, transclude) {
|
||||
|
||||
Reference in New Issue
Block a user