I'm new to angular, and i'm stuck with this issue, not sure why is this happening any thoughts would be helpful.
This is my service defined :
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
}]
Here window.app is mapped to angular.module('appName',[...])
This is my controller :
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
]
Thanks,
Your coffeescript seems odd. This:
then (result) ->
def.resolve result.data
should be:
then (result) ->
def.resolve result.data
Same thing for the second function
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.