我正在使用angular和bootstrap制作进度条。它现在正常工作,它正确显示了进度值。现在我希望我的进度条使用types=" "
,具体取决于我称为进度的属性的值。我尝试从UI Bootstrap和其他一些堆栈溢出示例实现代码,但我错过了一些东西。如何根据值更改进度栏颜色?
任何人都可以帮忙吗?谢谢你的时间。
的script.js
table.controller('workingPlan', function ($scope, $localStorage) {
$scope.$storage = $localStorage.$default({
"todos":[
{ "text":"starting work", "progress":10},
{ "text":"middle of work","progress":50},
{ "text":"lunch brake", "progress":70},
{ "text":"finished working", "progress":100}
]
});
$scope.changeType = function(todo) {
var type;
if (todo.progress < 30) {
type = 'success';
} else if (todo.progress < 60) {
type = 'info';
} else if (todo.progress < 90) {
type = 'warning';
} else {
type = 'danger';
}
$scope.type = type;
};
的index.html
<tr ng-repeat="todo in plan>
<td><progressbar animate="false" value="todo.progress" type="{{todo.type}}"><b>{{todo.progress}}% </b></progressbar></t
</tr>
请注意,你声明一changeType功能,但你不要在任何地方运行它:) –