Nevermind. Mystery solved.
Was passing a function call (someFn(argA,argB)) instead of passing a
function, that calls a function.
Probably was expecting a return call to pass as callback.
On Thursday, January 9, 2014 10:20:37 PM UTC+2, Pan Stav wrote:
>
> I have a form that upon submitting its controller sends the data to the
> server and the server replies with some Json. If controller receives a
> valid reply it fires a predefined callback, in this case it's a popup (or a
> modal, as some call it these days). All goes smooth, I have no technical
> issue with non of these functions. The problem is a mystical one. Instead
> of showing the popup after the confirmed reply from the server. The popup
> shows before there's any answer.
>
> I checked it with a timer and there's a define 100-200 milliseconds diff
> between sending the data and calling the callback.
>
> My code is organized in this fashion:
>
> function customTimer(label){
> var date = new Date();
> console.log(label,Date.parse(date) + date.getMilliseconds())
> }
>
> <button ng-click="doThatThing(data)">
>
> $scope.doThatThing = function(data){
> // defines url and json according to data
> $scope.sendForm(url,json,function(){
> // show popup
> customTimer('two');
> })
> }
>
> $scope.sendForm = function(url,json,callback){
> customTimer('one');
> server.post(url,json,function(){
> // do all sorts of different things and then:
> callback()
> })
> };
>
> And what happens is that 'two' logs before 'one', which doesn't make any
> sort of sense to me.
> Did anyone else came across this behaviour?
>
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.