0

I'm not getting it... I'd like to do a get request on my service which gives me the specific hardware for the barcode i scanned - this works already.

I get the correct hardware back as an object, looks like this ->

enter image description here

But if I want to display this object now, I only get [object Object] in my frontend.

component.html

{{ terminal }}

component.ts

terminal: any[] = [];

constructor(private terminalService: TerminalService) { }

this.terminalService.getTerminalByBarcode(barcode).subscribe(terminal => {
   console.log(terminal.terminal);
   this.terminal = terminal.terminal;
});

I already tried with terminal: Object; but that doesn't change anything. Hope someone can tell me, where I'm thinking wrong of two way data binding?

1
  • What do you exactly want to display on the UI as in what properties of the object you want to display?? Commented Feb 1, 2018 at 12:19

2 Answers 2

3

If terminal.terminal is an object, the output of {{ terminal }} is OK to be [object Object], because it calls toString on that object.

To see the structure of the terminal you can use json pipe

{{ terminal | json }}
Sign up to request clarification or add additional context in comments.

1 Comment

thanks a lot, | json is what did the trick! Will accept your answer as soon as it's possible
1

It's because on your view you are trying to output the actual object .toString.

You need to output the objects properties like the following:

{{ terminal.barcode }}
{{ terminal.dateArrival }} 

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.