Odometer.js init not going to work on templates of angular's ui-router, because they loaded after the scan. This directive solves the problem.
Created
May 16, 2014 03:39
-
-
Save JoeyGo23/49146d7ef48821190dc5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
app = angular.module 'app', ['app.directives'] | |
app.config -> | |
window.odometerOptions = {auto: false} | |
app.controller 'MainCtrl', ($scope) -> | |
$scope.myModel = 12345 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### | |
Should be used as <odometer ng-model="myModel"></odometer> | |
### | |
'use strict' | |
app = angular.module 'app.directives', [] | |
app.directive 'odometer', -> | |
restrict: 'E' | |
require: 'ngModel' | |
scope: | |
model: '=ngModel' | |
link: ($scope, el, attr) -> | |
o = new Odometer | |
el: el[0] | |
value: $scope.model | |
format: '' | |
duration: 300 | |
$scope.$watch "model", (newVal) -> | |
o.update newVal |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment