Angular.js : Polling Example
http://angularjs.org
HTML
<script src="http://code.jquery.com/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular.js"></script>
<script src="http://underscorejs.org/underscore-min.js"></script>
<div>
<div ng-controller="Ctrl1">
<div data-chart data-value="value"></div>
</div>
</div>
JavaScript
var myApp = angular.module('myApp', []);
myApp.controller('Ctrl1', function($scope, $timeout) {
$scope.value = 1;
var poll = function() {
$timeout(function() {
$scope.value++;
//poll();
}, 1000);
};
poll();
});
myApp.directive('chart', function() {
return {
restrict: 'A',
scope : {
value : '=' // '=' indicates 2 way binding
},
template : "<div> value : {{value}} </div>"
};
});