Original blog post here: http://www.andrewboni.com/2014/09/03/a-countupjs-angularjs-directive/
About
This is an AngularJS directive for the countUp.js library.
Dependencies
- AngularJS
- countUp.js
Installation
Install via Bower:
bower install -S countup-angularjs-directive
or NPM:
npm install countup-angularjs-directive
Then, add the module name to your app.js
or app.coffee
file:
modules = ... 'ngCountup' ...angularmodule'myApp'modulesrun...
...and include the file dist/countup-angularjs-directive.min.js
somewhere on your page, after angular
and countUp
.
Like so:
Usage
Note that you need the attribute count-up
, ng-model
, as well as an id
. The count-up
attribute is self explanatory, while the ng-model
is the numerical value to apply the countUp effect to. The id
is necessary for countUp itself- it doesn't matter what the name of the id
is.
Optionally, you can configure the number of decimals and the animation length (in seconds) like so:
This directive is a work in progress- there are probably a ton of optimzations that can be made. If you have any suggestions, please submit a pull request!