diff --git a/src/rating/rating.js b/src/rating/rating.js index 1ff9ebd6f4..86327c87a3 100644 --- a/src/rating/rating.js +++ b/src/rating/rating.js @@ -81,10 +81,7 @@ angular.module('ui.bootstrap.rating', []) replace: true, link: function(scope, element, attrs, ctrls) { var ratingCtrl = ctrls[0], ngModelCtrl = ctrls[1]; - - if ( ngModelCtrl ) { - ratingCtrl.init( ngModelCtrl ); - } + ratingCtrl.init( ngModelCtrl ); } }; }); \ No newline at end of file diff --git a/src/rating/test/rating.spec.js b/src/rating/test/rating.spec.js index 0a32707ffa..038bdd4f39 100644 --- a/src/rating/test/rating.spec.js +++ b/src/rating/test/rating.spec.js @@ -165,6 +165,17 @@ describe('rating directive', function () { expect($rootScope.rate).toBe(3); }); + it('supports only arrow keys', function() { + $rootScope.rate = undefined; + $rootScope.$digest(); + + triggerKeyDown(36); + expect($rootScope.rate).toBe(undefined); + + triggerKeyDown(41); + expect($rootScope.rate).toBe(undefined); + }); + it('can get zero value but not negative', function() { $rootScope.rate = 1; $rootScope.$digest();