当承诺在coffeescript中进行链接时,为此定义的函数需要绑定到'this'.
$q.fcall somecall
.then ((url)->
dosomething()
).bind(this)
.catch (err)->
console.log 'error occured', err
Run Code Online (Sandbox Code Playgroud)
但是,以上编译成以下内容,这是错误的.那怎么写呢?或者有没有办法让coffeescript代表这个?
$q.fcall(somecall).then(((function(url) {
dosomething()
}).bind(this))["catch"](function(err) {
return console.log('error occured', err);
})));
Run Code Online (Sandbox Code Playgroud)