Freelance Project Requests info@CodeDocu.de Software Development in C# WPF Asp.Net Core Vba Excel Word SQL-Server EF Linq, UWP Net
#

 

When you output energiser values in an Angular app, the data values are output as =[object Object].

How can you present these values as values in a console.log?

 

An Observable with an Article Value

 

articleArticleModel;

..
..
..
console
.log("article=" + this.article);

 

 

results in:

 

article=[object Object]

 

Concerns:

Javascript, Typescript / angular im Browser, Chrome, Observable

 

Lösung:

Mit JSON.stringify(this.article)); ()

 

In javascript/typescript code:

 

console.log("article=" + JSON.stringify(this.article));

 

Output in the browser

 

article={"idarticle":56,"iduserguid":"1428ca0b-186c-43c8-8ec6-08d26e97e83b","isowner":false,"title":"Über uns: wer sind wir ?","htmlcontent":"<div>async send_Data_to_Api() {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; //------&lt; send_Data_to_Api() &gt;------</div><div>&nbsp; &nbsp; &nbsp; &nbsp; console.log(this.state);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; //&lt; get text &gt;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; let element = document.getElementById('ctleditor_html');</div><div>&nbsp; &nbsp; &nbsp; &nbsp; let editor_innerhtml = element.innerHTML;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; let text_of_htmleditor = element.innerText;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; //&lt;/ get text &gt;</div><div><br></div>","textcontent":null,"folder":"@/Über uns","keywords":"Keyword 56","imagepath":"/User_Files/Articles/Images/Image_144_0_pad.jpg","dtcreated":null,"dtedit":null,"sumviews":0,"sumlikes":0,"sumcomments":0}

 

 

In the browser you can also examine the data in a breakpoint well by moving the cursor over the variable / Object / Array

 

Browser watch, Debug Ergibt bei this.article:

1.  dtcreatednull

2.  dteditnull

3.  folder"@/Über uns"

4.  htmlcontent"<div>async send_Data_to_Api() {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; //------&lt; send_Data_to_Api() &gt;------</div><div>&nbsp; &nbsp; &nbsp; &nbsp; console.log(this.state);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; //&lt; get text &gt;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; let element = document.getElementById('ctleditor_html');</div><div>&nbsp; &nbsp; &nbsp; &nbsp; let editor_innerhtml = element.innerHTML;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; let text_of_htmleditor = element.innerText;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; //&lt;/ get text &gt;</div><div><br></div>"

5.  idarticle56

6.  iduserguid"1428ca0b-186c-43c8-8ec6-08d26e97e83b"

7.  imagepath"/User_Files/Articles/Images/Image_144_0_pad.jpg"

8.  isownerfalse

9.  keywords"Keyword 56"

10. sumcomments0

11. sumlikes0

12. sumviews0

13. textcontentnull

14. title"Über uns: wer sind wir ?"

15. __proto__: Object

 

 

 

 

Loading a user value via Angular observable and displaying Article

 

load_userID() {

    this.dataService.get_UserIdGuid().subscribe(response => {

      console.log("get_UserIdGuid()=" + response);

      console.log("article=" + this.article);

      this.iduserguid = response;

      if(this.article.iduserguid==this.iduserguid){

        this.isOwner=true;

      }

      else  {

        this.isOwner=false;

      }

    }

    );

  }

 

 

Mobile

.

Contact for Jobs, Project Requests: raimund.popp@microsoft-programmierer.de