我已经在 angularjs 中实现了引导星级评分...一切正常,但在表单提交后无法获得最终评分值..下面是代码
//enter code here js
angular.module('plunker', ['ui.bootstrap']);
var RatingDemoCtrl = function ($scope) {
$scope.submit = function() {
console.log($scope.overStar) ; //giving always null
}
$scope.rate = 1;
$scope.max = 5;
$scope.isReadonly = false;
$scope.hoveringOver = function(value,object) {
$scope.overStar = value;
$scope.percent = 100 * (value / $scope.max);
};
};
enter code here html
<!doctype html>
<html ng-app="plunker">
<head>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.8/angular.js"></script>
<script src="http://angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.6.0.js"></script>
<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.min.css" rel="stylesheet">
</head>
<body>
<div ng-controller="RatingDemoCtrl" class="well well-small">
<form class="Scroller-Container" ng-submit="submit()" >
<rating value="rate" max="max" readonly="isReadonly" on-hover="hoveringOver(value)" on-leave="overStar = null" ></rating>
<span class="badge" ng-class="{'badge-warning': percent<30, 'badge-info': percent>=30 && percent<70, 'badge-success': percent>=70}" ng-show="overStar && !isReadonly">{{percent}}%</span>
</div>
<input type="submit" id="submit" value="Submit" />
</form>
</body>
</html>
我尝试使用 ng-click 设置值,但 ng-click 没有触发不知道你……之前有人做过……需要帮助……