AngularJS计数器计数到目标数 [英] AngularJS counter to count up to a target number

查看:637
本文介绍了AngularJS计数器计数到目标数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的角,并想实现的JQuery一样易于功能扩展,
但用指令(据我理解这是怎么应该做)。

I'm new to Angular, and would like to implement the same easy function extension in JQuery, but use directive (as far as i understand this is how it supposed to be done).

不知道有人为准备执行力度?

does somone know ready implimentation?

我的搜索结束了仅与jQuery的解决方案和我不知道如何将它转换成角。

my search ended up only with JQuery solutions and i don't know how to convert it to Angular.

这就是我需要做的:

链接,例如: http://jsfiddle.net/YWn9t/

您能帮忙吗?

函数声明:

$.fn.countTo.defaults = {
    from: 0,  // the number the element should start at
    to: 100,  // the number the element should end at
    speed: 1000,  // how long it should take to count between the target numbers
    refreshInterval: 100,  // how often the element should be updated
    decimals: 0,  // the number of decimal places to show
    onUpdate: null,  // callback method for every time the element is updated,
    onComplete: null,  // callback method for when the element finishes updating
};

如何使用:

jQuery(function($) {
        $('.timer').countTo({
            from: 50,
            to: 2500,
            speed: 5000,
            refreshInterval: 50,
            onComplete: function(value) {
                console.debug(this);
            }
        });
    });

HTML

<span class="timer"></span>

摘自:<一href=\"http://stackoverflow.com/questions/2540277/jquery-counter-to-count-up-to-a-target-number\">stackoverflow

推荐答案

看这个指令的http:/ /siddii.github.io/angular-timer/ 。我相信这符合所有您的要求。

Look at this directive http://siddii.github.io/angular-timer/ . I believe this meets all your requirements.

这篇关于AngularJS计数器计数到目标数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆