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

Commit

Permalink
fix(rating): re-expose RatingController
Browse files Browse the repository at this point in the history
- Re-expose `RatingController` with deprecation notice

Closes #4529
  • Loading branch information
wesleycho committed Oct 3, 2015
1 parent 5604e59 commit aede646
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
13 changes: 12 additions & 1 deletion src/rating/rating.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,17 @@ angular.module('ui.bootstrap.rating')

.value('$ratingSuppressWarning', false)

.controller('RatingController', ['$scope', '$attrs', '$controller', '$log', '$ratingSuppressWarning', function($scope, $attrs, $controller, $log, $ratingSuppressWarning) {
if (!$ratingSuppressWarning) {
$log.warn('RatingController is now deprecated. Use UibRatingController instead.');
}

angular.extend(this, $controller('UibRatingController', {
$scope: $scope,
$attrs: $attrs
}));
}])

.directive('rating', ['$log', '$ratingSuppressWarning', function($log, $ratingSuppressWarning) {
return {
require: ['rating', 'ngModel'],
Expand All @@ -112,7 +123,7 @@ angular.module('ui.bootstrap.rating')
onHover: '&',
onLeave: '&'
},
controller: 'UibRatingController',
controller: 'RatingController',
templateUrl: 'template/rating/rating.html',
replace: true,
link: function(scope, element, attrs, ctrls) {
Expand Down
5 changes: 3 additions & 2 deletions src/rating/test/rating.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,8 @@ describe('rating deprecation', function() {
var element = $compile('<rating ng-model="rate"></rating>')($rootScope);
$rootScope.$digest();

expect($log.warn.calls.count()).toBe(1);
expect($log.warn.calls.argsFor(0)).toEqual(['rating is now deprecated. Use uib-rating instead.']);
expect($log.warn.calls.count()).toBe(2);
expect($log.warn.calls.argsFor(0)).toEqual(['RatingController is now deprecated. Use UibRatingController instead.']);
expect($log.warn.calls.argsFor(1)).toEqual(['rating is now deprecated. Use uib-rating instead.']);
}));
});

0 comments on commit aede646

Please sign in to comment.