Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <h1>Angular Data Counter Directive</h1>

<div ng-app="app" ng-controller="controller" class="container">

  <adv-counter var="1.6" color="white" background="lightblue" symbol="£" icon="https://s3-us-west-2.amazonaws.com/s.cdpn.io/110131/Plane_black_shape_rotated_to_right_diagonal_32.png">Money spent on Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nihil, sapiente.</adv-counter>

  <adv-counter var="2.6" background="#339194" time=".5" decimal="0" icon="https://s3-us-west-2.amazonaws.com/s.cdpn.io/110131/Road_perspective_32.png">Amount of people that Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ea, velit.</adv-counter>

  <adv-counter var="16.5" background="#333333" color="#03A9F4" time="2" decimal="1" icon="https://s3-us-west-2.amazonaws.com/s.cdpn.io/110131/Barcode_32.png">Amount of products that Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ea, velit.</adv-counter>

  <adv-counter var="0.5" color="white" background="#F10C49" icon="https://s3-us-west-2.amazonaws.com/s.cdpn.io/110131/Plane_black_shape_rotated_to_right_diagonal_32.png">Flights that Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nihil, sapiente.</adv-counter>

  <adv-counter var="6.4" background="tomato" time="1" decimal="0" icon="https://s3-us-west-2.amazonaws.com/s.cdpn.io/110131/Road_perspective_32.png">Amount of cars that Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ea, velit.</adv-counter>

  <adv-counter var="2.3" background="#efefef" color="#03A9F4" time=".4" decimal="2" symbol="$" icon="https://s3-us-west-2.amazonaws.com/s.cdpn.io/110131/Barcode_32.png">Amount of dollars that Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ea, velit.</adv-counter>


</div>

<p>Angular Directive that creates a block displaying an increasing counter, with the ability to control variables such as multiple, interval time, decimal places, currency, style and icon from the HTML element attributes. 
<a href="http://toys.paradisecircus.com/realtime/" target="_blank">Inspired by this.</a>
</p>

<h2>Usage</h2>
<code><pre>
&lt;adv-counter var="MULTIPLE" time="INTERVAL_TIME(in seconds)" decimal="DECIMAL_PLACES" color="FOREGROUND_COLOR" background="BACKGROUND_COLOR" symbol="SYMBOL" icon="PATH/TO/IMG">

CONTENT 

&lt;/adv-counter>
</pre></code>

<p style="font-size:0.7em;">Icons by <a href="http://www.flaticon.com/authors/dave-gandy" title="Dave Gandy">Dave Gandy</a>            . Licensed by <a href="http://creativecommons.org/licenses/by/3.0/" title="Creative Commons BY 3.0">CC BY 3.0</a></p>
              
            
!

CSS

              
                * {
  box-sizing:border-box;
}

h1 {
  text-align: center;
  font-weight:bold;
  margin-bottom:30px;
}

h2 {
  text-align:center;
  font-weight:bold;
}

p {
  text-align:center;
  max-width:800px;
  margin:10px auto 30px;
  padding:10px;
}

pre {
  max-width:800px;
  margin:auto;
  width:95%;
}

img {
  max-width:100%;
  height:auto;
}

.container {
  @media screen and (min-width:640px){
    columns:3;
  }
}

.box {
  width:100%;
  display:inline-block;
  padding:10px;
  min-height:200px;
  margin:1%;
  list-style:none;

  .icon {
    float:right;
    max-width:40%;
  }

  .count {
    font-size:2.2em;
    font-weight:bold;
    float:left;
  }

  .content {
    display:block;
    clear:both;
    font-size:1.3em;
  }
}
              
            
!

JS

              
                (function() {
  var app = angular.module('app', []);

  app.controller('controller', function($scope) {

  }); // End Controller

  app.directive('advCounter', function($timeout) {

    function update(scope) {
      $timeout(function() {
        update(scope);
        scope.int += scope.var;
        scope.output = scope.int.toFixed(scope.decimal);
      }, scope.time * 1000);
    }

    return {
      restrict: 'E',
      transclude: true,
      scope: {
        var: '=',
        color: '@',
        background: '@',
        symbol: '@',
        time: '@',
        icon: '@',
        decimal: '@'
      },
      link: function(scope) {
        scope.int = 0;
        scope.time = 1;
        scope.decimal = 2;
        update(scope);
      },
      template: '<li class="box" ng-style="{color:color,background:background}"><span class="count">{{symbol}}{{output}}</span><span class="icon"><img ng-src="{{icon}}"/></span><span class="content" ng-transclude></span></li>'
    };
  });

})();
              
            
!
999px

Console