This repository was archived by the owner on May 29, 2019. It is now read-only.
File tree 4 files changed +11
-2
lines changed
4 files changed +11
-2
lines changed Original file line number Diff line number Diff line change 1
1
< 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 >
3
4
4
5
< hr />
5
6
< 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 1
1
var RatingDemoCtrl = function ( $scope ) {
2
2
$scope . rate = 7 ;
3
+ $scope . max = 10 ;
3
4
$scope . isReadonly = false ;
4
5
$scope . hoveringOver = function ( value ) {
5
6
$scope . overStar = value ;
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ angular.module('ui.bootstrap.rating', [])
16
16
replace : true ,
17
17
link : function ( scope , element , attrs ) {
18
18
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 ;
20
20
21
21
scope . range = [ ] ;
22
22
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 () {
77
77
expect ( getStars ( ) . length ) . toBe ( 7 ) ;
78
78
} ) ;
79
79
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
+
80
87
it ( 'handles readonly attribute' , function ( ) {
81
88
$rootScope . isReadonly = true ;
82
89
element = $compile ( '<rating value="rate" readonly="isReadonly"></rating>' ) ( $rootScope ) ;
You can’t perform that action at this time.
0 commit comments