diff --git a/src/rating/docs/demo.html b/src/rating/docs/demo.html index 5182fafdf7..9eb7b7d417 100644 --- a/src/rating/docs/demo.html +++ b/src/rating/docs/demo.html @@ -1,5 +1,6 @@
Rate: {{rate}} - Readonly is: {{isReadonly}} - Hovering over: {{overStar || "none"}}diff --git a/src/rating/docs/demo.js b/src/rating/docs/demo.js index bd69a0be57..428c5956ac 100644 --- a/src/rating/docs/demo.js +++ b/src/rating/docs/demo.js @@ -1,5 +1,6 @@ var RatingDemoCtrl = function ($scope) { $scope.rate = 7; + $scope.max = 10; $scope.isReadonly = false; $scope.hoveringOver = function(value) { $scope.overStar = value; diff --git a/src/rating/rating.js b/src/rating/rating.js index ff3a18d1eb..facef1561c 100644 --- a/src/rating/rating.js +++ b/src/rating/rating.js @@ -16,7 +16,7 @@ angular.module('ui.bootstrap.rating', []) replace: true, link: function(scope, element, attrs) { - var maxRange = angular.isDefined(attrs.max) ? scope.$eval(attrs.max) : ratingConfig.max; + var maxRange = angular.isDefined(attrs.max) ? scope.$parent.$eval(attrs.max) : ratingConfig.max; scope.range = []; for (var i = 1; i <= maxRange; i++) { diff --git a/src/rating/test/rating.spec.js b/src/rating/test/rating.spec.js index 9a9e368db4..64b5e2bb48 100644 --- a/src/rating/test/rating.spec.js +++ b/src/rating/test/rating.spec.js @@ -77,6 +77,13 @@ describe('rating directive', function () { expect(getStars().length).toBe(7); }); + it('shows different number of icons when `max` attribute is from scope variable', function() { + $rootScope.max = 15; + element = $compile('