Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Commit

Permalink
fix(rating): make deprecated controller work with 1.3.x
Browse files Browse the repository at this point in the history
Closes #4582
  • Loading branch information
Foxandxss authored and wesleycho committed Oct 11, 2015
1 parent 1c5e479 commit ce1114a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/rating/rating.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -39,15 +39,15 @@ angular.module('ui.bootstrap.rating', [])
}
return states;
};

this.getTitle = function(index) {
if (index >= this.titles.length) {
return index + 1;
} else {
return this.titles[index];
}
};

$scope.rate = function(value) {
if (!$scope.readonly && value >= 0 && value <= $scope.range.length) {
ngModelCtrl.$setViewValue(ngModelCtrl.$viewValue === value ? 0 : value);
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit ce1114a

Please sign in to comment.