docs(ionSlideView): add configurable model

This commit is contained in:
Andy Joslin
2014-03-10 20:15:57 -06:00
parent 1cf6355f7b
commit 68ddbdb439
4 changed files with 17 additions and 8 deletions

View File

@@ -32,6 +32,7 @@ angular.module('ionic.ui.slideBox', [])
* </ion-slide-box>
* ```
*
* @param {expression=} model The model to assign this slide box container's {@link ionic.controller:ionicSlideBox ionicSlideBox} controller to. By default, assigns to $scope.slideBoxController.
* @param {boolean=} does-continue Whether the slide box should automatically slide.
* @param {number=} slide-interval How many milliseconds to wait to change slides (if does-continue is true). Defaults to 4000.
* @param {boolean=} show-pager Whether a pager should be shown for this slide box.
@@ -52,7 +53,7 @@ angular.module('ionic.ui.slideBox', [])
onSlideChanged: '&',
activeSlide: '=?'
},
controller: ['$scope', '$element', function($scope, $element) {
controller: ['$scope', '$element', '$attrs', '$parse', function($scope, $element, $attrs, $parse) {
var _this = this;
var continuous = $scope.$eval($scope.doesContinue) === true;
@@ -98,7 +99,7 @@ angular.module('ionic.ui.slideBox', [])
slider.slide(index);
});
$scope.$parent.slideBox = slider;
$parse($attrs.model || 'slideBoxController').assign($scope.$parent, slider);
$ionicSlideBoxDelegate.register($scope, $element);

View File

@@ -18,7 +18,7 @@ angular.module('ionic.ui.service.slideBoxDelegate', [])
return;
}
$timeout(function() {
$scope.$parent.slideBox.setup();
$scope.$parent.slideBoxController.setup();
});
e.preventDefault();
});

View File

@@ -32,12 +32,20 @@ describe('Ionic Angular Slide Box', function() {
it('Should init', function() {
var scope = el.scope();
expect(scope.slideBox).not.toBe(undefined);
expect(scope.slideBoxController).toBeDefined()
expect(scope.slideBoxController.slide).toBeDefined();
});
it('Should init with custom model attr', inject(function($compile, $rootScope) {
var el = $compile('<ion-slide-box model="myModel"></ion-slide-box>')($rootScope);
var scope = el.scope();
expect(scope.myModel).toBeDefined();
expect(scope.myModel.slide).toBeDefined();
}));
it('Should update with delegate', function() {
var scope = el.scope();
var slideBox = scope.slideBox;
var slideBox = scope.slideBoxController;
spyOn(slideBox, 'setup');
delegate.update();
timeout.flush();
@@ -62,6 +70,6 @@ describe('Ionic Angular Slide Box', function() {
</ion-slide-box>')(rootScope);
var scope = el.scope();
expect(scope.slideBox.currentIndex()).toBe(2);
expect(scope.slideBoxController.currentIndex()).toBe(2);
});
});

View File

@@ -524,7 +524,7 @@ ionic.views.Slider = ionic.views.View.inherit({
/**
* @ngdoc method
* @name ionicSlideBox#currentIndex
* @returns {number} index The index of the current slide.
* @returns number The index of the current slide.
*/
this.currentIndex = function() {
// return current index position
@@ -534,7 +534,7 @@ ionic.views.Slider = ionic.views.View.inherit({
/**
* @ngdoc method
* @name ionicSlideBox#slidesCount
* @returns {number} count The number of slides there are currently.
* @returns number The number of slides there are currently.
*/
this.slidesCount = function() {
// return total number of slides