From dbfb7c016683582807463f48cbac21c288b98650 Mon Sep 17 00:00:00 2001 From: Foxandxss Date: Sun, 11 Oct 2015 18:47:31 +0200 Subject: [PATCH] fix(rating): make deprecated controller work with 1.3.x --- src/rating/rating.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/rating/rating.js b/src/rating/rating.js index 6f4d67f673..b32a1a371f 100644 --- a/src/rating/rating.js +++ b/src/rating/rating.js @@ -23,10 +23,10 @@ angular.module('ui.bootstrap.rating', []) this.stateOn = angular.isDefined($attrs.stateOn) ? $scope.$parent.$eval($attrs.stateOn) : ratingConfig.stateOn; this.stateOff = angular.isDefined($attrs.stateOff) ? $scope.$parent.$eval($attrs.stateOff) : ratingConfig.stateOff; - var tmpTitles = angular.isDefined($attrs.titles) ? $scope.$parent.$eval($attrs.titles) : ratingConfig.titles ; + var tmpTitles = angular.isDefined($attrs.titles) ? $scope.$parent.$eval($attrs.titles) : ratingConfig.titles ; this.titles = angular.isArray(tmpTitles) && tmpTitles.length > 0 ? tmpTitles : ratingConfig.titles; - + var ratingStates = angular.isDefined($attrs.ratingStates) ? $scope.$parent.$eval($attrs.ratingStates) : new Array(angular.isDefined($attrs.max) ? $scope.$parent.$eval($attrs.max) : ratingConfig.max); @@ -39,7 +39,7 @@ angular.module('ui.bootstrap.rating', []) } return states; }; - + this.getTitle = function(index) { if (index >= this.titles.length) { return index + 1; @@ -47,7 +47,7 @@ angular.module('ui.bootstrap.rating', []) return this.titles[index]; } }; - + $scope.rate = function(value) { if (!$scope.readonly && value >= 0 && value <= $scope.range.length) { ngModelCtrl.$setViewValue(ngModelCtrl.$viewValue === value ? 0 : value); @@ -109,10 +109,10 @@ angular.module('ui.bootstrap.rating') $log.warn('RatingController is now deprecated. Use UibRatingController instead.'); } - return $controller('UibRatingController', { + angular.extend(this, $controller('UibRatingController', { $scope: $scope, $attrs: $attrs - }); + })); }]) .directive('rating', ['$log', '$ratingSuppressWarning', function($log, $ratingSuppressWarning) {