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

fix(rating): make deprecated controller work with 1.3.x #4582

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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