Coffeescript将promise的finally()方法视为一个属性
coffescript弄乱了promise的.finall()方法,并使其成为Coffeescript将promise的finally()方法视为一个属性,coffeescript,Coffeescript,coffescript弄乱了promise的.finall()方法,并使其成为})[“finally”](function(){),而不是将其作为promise对象的方法调用 angular.module("main.loadbalancer") .controller "CreateNodeCtrl", ($scope, $modalInstance, LoadBalancerService, StatusTrackerService, NodeService) -> $scop
})[“finally”](function(){
),而不是将其作为promise对象的方法调用
angular.module("main.loadbalancer")
.controller "CreateNodeCtrl", ($scope, $modalInstance,
LoadBalancerService, StatusTrackerService, NodeService) ->
$scope.createNode = (node) ->
$scope.disableButtonsForRun = false
$scope.statusBar = true
$scope.nodeStatus = "Building"
$scope.statusType = "warning"
LoadBalancerService.getLoadBalancer().then (loadBalancer) ->
NodeService.createNode(
account_number: foo
admin_state: "enabled"
label: node.label
ip: node.ip
port: node.port
comment: node.comment
health_strategy: {}
vendor_extensions: {}
).then((eventId) ->
$scope.disableButtonsForRun = true
trackStatus = StatusTrackerService.runEventCheck "9936", "0fd6afd9-4aa0-a5c9-ff0b3e60cdcf"
trackStatus.then (( ->
$scope.statusType = "success"
$scope.nodeStatus = "Completed Successfully"
setTimeout ( ->
$modalInstance.close()
return
), 3000
), ( ->
$scope.nodeStatus = "Failure!"
$scope.statusType = "danger"
))
.finally ->
$scope.disableButtonsForRun = false
您发布的缩进不一致。最后一行,第34行:
$scope.disableButtonsForRun=false
,具有额外的缩进级别
试试这个:
angular.module("main.loadbalancer")
.controller "CreateNodeCtrl", ($scope, $modalInstance,
LoadBalancerService, StatusTrackerService, NodeService) ->
$scope.createNode = (node) ->
$scope.disableButtonsForRun = false
$scope.statusBar = true
$scope.nodeStatus = "Building"
$scope.statusType = "warning"
LoadBalancerService.getLoadBalancer().then (loadBalancer) ->
NodeService.createNode(
account_number: foo
admin_state: "enabled"
label: node.label
ip: node.ip
port: node.port
comment: node.comment
health_strategy: {}
vendor_extensions: {}
).then((eventId) ->
$scope.disableButtonsForRun = true
trackStatus = StatusTrackerService.runEventCheck "9936", "0fd6afd9-4aa0-a5c9-ff0b3e60cdcf"
trackStatus.then (( ->
$scope.statusType = "success"
$scope.nodeStatus = "Completed Successfully"
setTimeout ( ->
$modalInstance.close()
return
), 3000
), ( ->
$scope.nodeStatus = "Failure!"
$scope.statusType = "danger"
))
.finally ->
$scope.disableButtonsForRun = false
你有13个开始大括号,只有12个结束大括号 可能需要额外的
(
此处:
trackStatus.then ((
# ^
$scope.statusType = "success"
$scope.nodeStatus = "Completed Successfully"
对于我来说,使用coffee脚本1.7.1:
z仍然无法编译。coffee:34:46:错误:不匹配的OUTDENT
@SylvainLeroux确切地说,不清楚()
应该在嵌套的中的何处结束。然后()
sCoffeescript编译“finally”函数使用此符号,但为了与ES3兼容,需要使用此符号。来源:
angular.module("main.loadbalancer")
.controller "CreateNodeCtrl", ($scope, $modalInstance,
LoadBalancerService, StatusTrackerService, NodeService) ->
$scope.createNode = (node) ->
$scope.disableButtonsForRun = false
$scope.statusBar = true
$scope.nodeStatus = "Building"
$scope.statusType = "warning"
LoadBalancerService.getLoadBalancer().then (loadBalancer) ->
NodeService.createNode(
account_number: foo
admin_state: "enabled"
label: node.label
ip: node.ip
port: node.port
comment: node.comment
health_strategy: {}
vendor_extensions: {}
).then((eventId) ->
$scope.disableButtonsForRun = true
trackStatus = StatusTrackerService.runEventCheck "9936", "0fd6afd9-4aa0-a5c9-ff0b3e60cdcf"
trackStatus.then (( ->
$scope.statusType = "success"
$scope.nodeStatus = "Completed Successfully"
setTimeout ( ->
$modalInstance.close()
return
), 3000
), ( ->
$scope.nodeStatus = "Failure!"
$scope.statusType = "danger"
))
.finally ->
$scope.disableButtonsForRun = false
trackStatus.then ((
# ^
$scope.statusType = "success"
$scope.nodeStatus = "Completed Successfully"