This repository was archived by the owner on May 29, 2019. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11< div ng-controller ="RatingDemoCtrl ">
2- < rating value ="rate " max ="10 " readonly ="isReadonly " on-hover ="hoveringOver(value) " on-leave ="overStar = null "> </ rating >
2+ < rating value ="rate " max ="max " readonly ="isReadonly " on-hover ="hoveringOver(value) " on-leave ="overStar = null "> </ rating >
3+ < span class ="badge badge-inverse " ng-show ="overStar && !isReadonly "> {{overStar}} / {{max}}</ span >
34
45 < hr />
56 < pre > Rate: < b > {{rate}}</ b > - Readonly is: < i > {{isReadonly}}</ i > - Hovering over: < b > {{overStar || "none"}}</ b > </ pre >
Original file line number Diff line number Diff line change 11var RatingDemoCtrl = function ( $scope ) {
22 $scope . rate = 7 ;
3+ $scope . max = 10 ;
34 $scope . isReadonly = false ;
45 $scope . hoveringOver = function ( value ) {
56 $scope . overStar = value ;
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ angular.module('ui.bootstrap.rating', [])
1616 replace : true ,
1717 link : function ( scope , element , attrs ) {
1818
19- var maxRange = angular . isDefined ( attrs . max ) ? scope . $eval ( attrs . max ) : ratingConfig . max ;
19+ var maxRange = angular . isDefined ( attrs . max ) ? scope . $parent . $ eval( attrs . max ) : ratingConfig . max ;
2020
2121 scope . range = [ ] ;
2222 for ( var i = 1 ; i <= maxRange ; i ++ ) {
Original file line number Diff line number Diff line change @@ -77,6 +77,13 @@ describe('rating directive', function () {
7777 expect ( getStars ( ) . length ) . toBe ( 7 ) ;
7878 } ) ;
7979
80+ it ( 'shows different number of icons when `max` attribute is from scope variable' , function ( ) {
81+ $rootScope . max = 15 ;
82+ element = $compile ( '<rating value="rate" max="max"></rating>' ) ( $rootScope ) ;
83+ $rootScope . $digest ( ) ;
84+ expect ( getStars ( ) . length ) . toBe ( 15 ) ;
85+ } ) ;
86+
8087 it ( 'handles readonly attribute' , function ( ) {
8188 $rootScope . isReadonly = true ;
8289 element = $compile ( '<rating value="rate" readonly="isReadonly"></rating>' ) ( $rootScope ) ;
You can’t perform that action at this time.
0 commit comments