How to log
a Observable Array
If you try
to log a observable of a array than you will get:
console.log('data=' + data);
|
Console:
Solution:
Subscribe the
observable and log the items
console.dir(data.subscribe(item=>console.log(item)));
|
Following codes
where tested
findAll(): Observable <Article[]> {
var data=from(this.articleRepository.find());
//*LOG
: [object Object]
console.log('data=' + data); //=data=[object
Object]
console.log(data); //Observable
{ _subscribe: [Function (anonymous)] }
console.log(data.subscribe); //[object
Object] Observable { _subscribe: [Function (anonymous)] } [Function
(anonymous)]
console.dir(data.subscribe); //[object
Object] Observable { _subscribe: [Function (anonymous)] } [Function
(anonymous)]
//<
OK >
console.dir(data.subscribe(item=>console.log(item))); //*OK
: [Article {guidarticle: '3',content_title: null,...
//</ OK >
return data;
}
|