我是棱角分明的新手,我坚持这个问题,不知道为什么会这样 任何想法都会有所帮助。
这是我定义的服务:
window.app.factory 'fetchService', ['$http', '$q', '$location', ($http, $q, $location) ->
{
estimate: (newEstimate) ->
def = $q.defer()
$http.post('/v2/delivery_estimates', newEstimate).
then (result) ->
def.resolve result.data
, (result) ->
def.reject result.data
def.promise
}]
这里window.app映射到angular.module('appName',[...])
这是我的控制者:
window.app.controller 'deliveryCtrl', [ 'fetchService', (fetchService) ->
$scope.setDefaults = ->
{.... few code ....}
fetchService.estimate(initialEstimate)
.then (result) ->
$scope.dWindows = result.delivery_windows
$scope.uWindows = result.unavailable_windows
]
谢谢,
答案 0 :(得分:2)
你的coffeescript看起来很奇怪。这样:
then (result) ->
def.resolve result.data
应该是:
then (result) ->
def.resolve result.data
第二个功能
也是如此