when I define the factory method like this
dataFactory.all = function() {
return 'test01';
}
and call it in controller like this
console.log(Data.all());
I can get test01
printed. However, when I add some logic in factory all()
method like this
dataFactory.all = function() {
$http
.get('/api/hey')
.success(function(data) {
$http
.get('/api/hi')
.success(function(data) {
return 'test'; // 'test' can not be printed, and console show 'undefined'
});
});
//return 'test01'; //can be printed;
};
then the 'test' can not be printed via the controller. Because I put the return
statement in the callback?
Please let me know what I am doing wrong?
Thanks.