1) I want to understand why the two lines of code highlighted in BOLD letters wont work and i have to use the .then function to make it work?
2) also can you explain these syntax in a detailed way to that we understand when to use .then...etc?


var app = angular.module("myModule", []);
app.controller("myCtrl", function ($scope, myWebServices) {

myWebServices.Comments().then(function (returnedData) {
$scope.myComments = returnedData;
console.log($scope.myComments);
});
//$scope.myComments = myWebServices.Comments();
//console.log($scope.myComments);
});

app.service("myWebServices", function ($http) {
this.Comments = function () {
var abc = $http.get(" jsonplaceholder.typicode.com/comments ").then(function (Response) {
return (Response.data);
})
return abc;
}
});

Read More...