this seems like it should be delivering data to my scope, but it isn't, is there anything that directly jumps out as wrong with the below code ?
angular.module('Lunch.services', [])
.factory 'LunchMates', ($q, $http) ->
LunchMates =
getLunchMates: () ->
d = $q.defer();
$http.get('/lunchers').then (response, status) ->
if response.status == 200
d.resolve(response.data)
return d.promise
return LunchMates
angular.module('Lunch.controllers', [])
.controller('LunchCtrl', ($scope, LunchMates) ->
$scope.lunchers = LunchMates.getLunchMates()
)
This code:
$scope.lunchers = LunchMates.getLunchMates()
sets a promise on the scope, it relies on an old deprecated functionality.As of version >=1.2, promise unwrapping is deprecated, this is the breaking commit:
You can still enable it with
$parseProvider
like so:But it would break in future versions (as mentioned above), so instead do this:
This issue (among some others) is very common, mostly because lots of tutorials & books that new developers find all over the web, was written before version 1.2 and therefore not up-to-date. Always keep yourself up-to-date with the https://github.com/angular/angular.js/blob/master/CHANGELOG.md