本文实例讲述了Angular实现的进度条功能。分享给大家供大家参考,具体如下:
项目里需要一个进度条,所以就在网上查找资料学习,看到了网友“雪狼”的代码分享,写的很高明,很精练,很厉害,原文中的代码如下:
HTML部分:
<div ng-class="{progress: true, 'progress-striped': vm.striped}"> <div ng-class="['progress-bar', vm.style]" ng-style="{width: vm.value + '%'}"> <div ng-if="vm.showLabel">{{vm.value}}%</div> </div> </div> <h3>选项</h3> <label>进度:<input type="number" class="form-control" ng-model="vm.value"/></label> <button class="btn btn-primary" ng-click="vm.value=0">0%</button> <button class="btn btn-primary" ng-click="vm.value=20">20%</button> <button class="btn btn-primary" ng-click="vm.value=60">60%</button> <button class="btn btn-primary" ng-click="vm.value=100">100%</button> <hr/> <label>斑马纹<input type="checkbox" ng-model="vm.striped"/></label> <label>文字<input type="checkbox" ng-model="vm.showLabel"/></label> <hr/> <label>风格: <select ng-model="vm.style" class="form-control"> <option value="progress-bar-success">progress-bar-success</option> <option value="progress-bar-info">progress-bar-info</option> <option value="progress-bar-danger">progress-bar-danger</option> <option value="progress-bar-warning">progress-bar-warning</option> </select> </label>
JS部分:
'use strict'; angular.module('ngShowcaseApp').controller('ctrl.show.progress', function ($scope) { var vm = $scope.vm = {}; vm.value = 50; vm.style = 'progress-bar-info'; vm.showLabel = true; });
这里结合自己的项目需要,自己改编了个简单的进度条,可以加在项目里面,进度条的开始和结束由自己决定。
1. js代码
var myApp = angular.module('myApp', []); myApp.controller('main', ['$scope', '$interval', function($scope, $interval){ var vm = $scope.vm = {}; vm.value = 0; vm.style = 'progress-bar-danger'; vm.showLabel = true; vm.striped = true; $scope.selectValue = function (){ console.log(vm.style); }; var index = 0; var timeId = 500; $scope.count = function(){ var start = $interval(function(){ vm.value = ++index; if (index > 99) { $interval.cancel(start); } if (index == 60) { index = 99; } }, timeId); }; }]);
2. html代码
<div ng-class="{progress: true, 'progress-striped': vm.striped}" class="col-md-4"> <div ng-class="['progress-bar', vm.style]" ng-style="{width: vm.value + '%'}"> <div ng-if="vm.showLabel">{{vm.value}}%</div> </div> </div> <button class="btn btn-success" ng-click="count()">开始进度</button>
更多关于AngularJS相关内容感兴趣的读者可查看本站专题:《AngularJS指令操作技巧总结》、《AngularJS入门与进阶教程》及《AngularJS MVC架构总结》
希望本文所述对大家AngularJS程序设计有所帮助。
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
《魔兽世界》大逃杀!60人新游玩模式《强袭风暴》3月21日上线
暴雪近日发布了《魔兽世界》10.2.6 更新内容,新游玩模式《强袭风暴》即将于3月21 日在亚服上线,届时玩家将前往阿拉希高地展开一场 60 人大逃杀对战。
艾泽拉斯的冒险者已经征服了艾泽拉斯的大地及遥远的彼岸。他们在对抗世界上最致命的敌人时展现出过人的手腕,并且成功阻止终结宇宙等级的威胁。当他们在为即将于《魔兽世界》资料片《地心之战》中来袭的萨拉塔斯势力做战斗准备时,他们还需要在熟悉的阿拉希高地面对一个全新的敌人──那就是彼此。在《巨龙崛起》10.2.6 更新的《强袭风暴》中,玩家将会进入一个全新的海盗主题大逃杀式限时活动,其中包含极高的风险和史诗级的奖励。
《强袭风暴》不是普通的战场,作为一个独立于主游戏之外的活动,玩家可以用大逃杀的风格来体验《魔兽世界》,不分职业、不分装备(除了你在赛局中捡到的),光是技巧和战略的强弱之分就能决定出谁才是能坚持到最后的赢家。本次活动将会开放单人和双人模式,玩家在加入海盗主题的预赛大厅区域前,可以从强袭风暴角色画面新增好友。游玩游戏将可以累计名望轨迹,《巨龙崛起》和《魔兽世界:巫妖王之怒 经典版》的玩家都可以获得奖励。
更新日志
- 大自然音乐系列《听见向日葵的微笑》[WAV/CUE/分轨][538.5MB]
- 魔兽世界地心之战戒律牧用什么饰品 地心之战戒律牧饰品推荐
- 魔兽世界地心之战戒律牧用什么合剂食物 地心之战戒律牧合剂食物推荐
- 仙境传说新启航职业排行榜大全 仙境传说最强职业是哪个
- 群星《网络新歌曲速报》3CD[DTS-WAV分轨]
- 群星《男人必听》一张男人开车时必听的绝世好歌[WAV]
- 群星《再见新歌》2CD【DTS-WAV分轨】
- 黎瑞恩.1992-雨季不再来【宝丽金】【WAV+CUE】
- 曹雅雯.2018-小说【美乐蒂】【FLAC分轨】
- 温拿乐队.2007-温拿33好时光演唱会2CD(2024环球红馆40复刻系列)【环球】【WAV+CUE】
- 魔兽世界地心之战戒律牧用什么附魔宝石 地心之战戒律牧附魔宝石推荐
- 仙境传说新启航公测兑换码汇总 仙境传说最新兑换码礼包大全
- 魔兽世界地心之战神牧用什么饰品 地心之战神牧饰品推荐
- 群星《聆听·极致女声》2CD[DTS-WAV]
- 群星《五大最美女中音》2CD[DTS-WAV]