strange behaviour in angularjs when using timer to update scope

I am writing a timer directive to output the result of a function using a time loop.

http://jsfiddle.net/U3q4U/1/

now the problem I have is that the code works perfectly on jsfiddle - the date updates itself every 4 seconds whilst the numbers increase by 1 every second.

but if you copy and paste the code into a html file (and link to the angularjs library) calling $apply on scope does not work properly - the numbers do not update at regular intervals and will jump (eg from 5 to 8).

The directive in question is this:

<gx:timer interval="1000" fn="fn1" output="out"></gx:timer>

I've tried this on both firefox and chrome. the behaviour are the same.

Updated your jsfiddle and got it working outside js fiddle w/o issues

The issue might be the multiple <script> tags you are using and defining the same module twice

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