diff --git a/js/ext/angular/src/directive/ionicContent.js b/js/ext/angular/src/directive/ionicContent.js index 8fb52f8be7..e83a56a082 100644 --- a/js/ext/angular/src/directive/ionicContent.js +++ b/js/ext/angular/src/directive/ionicContent.js @@ -48,7 +48,7 @@ angular.module('ionic.ui.content', ['ionic.ui.scroll']) * with {@link ionic.service:$ionicScrollDelegate}. * @param {boolean=} padding Whether to add padding to the content. * of the content. Defaults to true on iOS, false on Android. - * @param {boolean=} scroll Whether to allow scrolling of content. Defaults to true. + * @param {boolean=} scroll Whether to allow scrolling of content. Defaults to true. Note: scroll="false" removes the .scroll child element on element compilation, not on scope change * @param {boolean=} overflow-scroll Whether to use overflow-scrolling instead of * Ionic scroll. * @param {boolean=} has-bouncing Whether to allow scrolling to bounce past the edges @@ -66,12 +66,17 @@ function($timeout, $controller, $ionicBind) { require: '^?ionNavView', scope: true, compile: function(element, attr) { + var innerElement; + element.addClass('scroll-content'); - //We cannot transclude here because it breaks element.data() inheritance on compile - var innerElement = angular.element('
'); - innerElement.append(element.contents()); - element.append(innerElement); + if (attr.scroll != 'false') { + //We cannot use normal transclude here because it breaks element.data() + //inheritance on compile + innerElement = angular.element(''); + innerElement.append(element.contents()); + element.append(innerElement); + } return { pre: prelink }; function prelink($scope, $element, $attr, navViewCtrl) { @@ -104,7 +109,7 @@ function($timeout, $controller, $ionicBind) { if (angular.isDefined($attr.padding)) { $scope.$watch($attr.padding, function(newVal) { - innerElement.toggleClass('padding', !!newVal); + (innerElement || $element).toggleClass('padding', !!newVal); }); } diff --git a/js/ext/angular/test/directive/ionicContent.unit.js b/js/ext/angular/test/directive/ionicContent.unit.js index 5d481d99c8..e8fe9e1024 100644 --- a/js/ext/angular/test/directive/ionicContent.unit.js +++ b/js/ext/angular/test/directive/ionicContent.unit.js @@ -60,14 +60,41 @@ describe('Ionic Content directive', function() { }); }); - it('should add padding classname', function() { + it('should have no scroll element when scroll="false"', function() { + var element = compile('