This is, I believe, what is causing the Issue in this pervious Question. I have looked here and here but I still am not understanding what is happening. When I log to the console the value of temp
I get the result 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31
as expected but when I use var month = $q.defer()
and month.resolve(temp)
and try to log the value of month.promise
I get [Object object]
instead of the same as temp.
Is that what should be Expected?
if No - What am I doing incorrect ( This is why I I'm using $q.defer() in case its a factor)
if Yes - How Can I convert month.promise
to a more consumable form? i.e. if temp is an array how to I access month.promise
as an array where temp[0] = month.promise[0]
below is my code example but all of my controller & service can be found here, I basically want to just return an array (or JSON) to my controller instead of [Object object]
var month = $q.defer();
$http.get('getMonth.php?date=' + date)
.success(function (data, status, headers, config) {
var temp = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31];
console.log("Temp : " + temp + " !!!");
month.resolve(temp);
//month.resolve(data);
//console.log("data "+data[0]);
console.log("resolved " + month);
console.log("resolved[0] " + month[0]);
console.log("resolved.promise " + month.promise + " !!!");
console.log("resolved.promise[0] " + month.promise[0]);
});
UPDATE
on the advice of @CuongLe below I have added the below code and I can successfully log my data but I still get [Object object]
when I return it
var promise = month.promise;
promise.then(
function (data) {
console.log(data);
});