我是angular的新手,我一直在处理这个问题,不确定为什么会发生这种情况任何想法都会有所帮助。
这是我定义的服务:
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
]
谢谢,
你的咖啡脚本看起来很奇怪。此:
then (result) ->
def.resolve result.data
应该是:
then (result) ->
def.resolve result.data
第二个函数也是如此