digest error on sucess() over then() angularjs with typescript -


i created angular js service in typescript post file , when successful used alert() notify user.

uploadfiletourl = (file, uploadurl) =>  {     var fd = new formdata();     fd.append('file', file);     this.$http.post(uploadurl, fd, {         transformrequest: angular.identity,         headers: { 'content-type': undefined }     })     .success(() => {         alert("file uploaded");     })     .error(() => {         alert("some error occured.");     }); } 

i can debug code , verify call indeed successful, when call returns, shows success , theres digest error if return promise service , in controller use then() , works fine.

uploadfiletourl = (file, uploadurl) => {     var fd = new formdata();     fd.append('file', file);     return this.$http.post(uploadurl, fd, {         transformrequest: angular.identity,         headers: { 'content-type': undefined }     }) } 

i wanted know problem success() , if then() should preferred on success().

the promise mechanism in angular provided $q.

few weeks ago, had seen promise.success() , promise.error() deprecated. both don't appear in documentation anymore.

so, i'd suggest avoid using success() , error() , use then(successfunction, errorfunction); instead.

documentation here

edit

after having checked source code, can ensure .success , .error don't exist anymore latest angular source code

https://github.com/angular/angular.js/blob/master/src/ng/q.js#l3


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

c# - two queries in same method -