(I recently posted this question as part of another issue I was having and 
wanted to break it out separately, will link back shortly....)

I have a service call in Angular that returns the following JSON data 
(results of a console.log()):


   1. (7) [{…}, {…}, {…}, {…}, {…}, {…}, {…}]
      1. 0:{ID: 1, ORDERNO: 160, CREW: 2, JOBNUMBER: 1702377, YARDS: 40, …}
      2. 1:{ID: 2, ORDERNO: 44, CREW: 3, JOBNUMBER: 1702391, YARDS: 90, …}
      3. 2:{ID: 3, ORDERNO: 19, CREW: 5, JOBNUMBER: 1702294, YARDS: 30, …}
      4. 3:{ID: 4, ORDERNO: 66, CREW: 6, JOBNUMBER: 1702364, YARDS: 55, …}
      5. 4:{ID: 5, ORDERNO: 69, CREW: 7, JOBNUMBER: 1702272, YARDS: 170, …}
      6. 5:{ID: 6, ORDERNO: 102, CREW: 9, JOBNUMBER: 1702321, YARDS: 10, …}
      7. 6:{ID: 7, ORDERNO: 36, CREW: 10, JOBNUMBER: 1702289, YARDS: 80, …}
      8. length:7
   
So you can see I'm obviously getting the data back - console.log() let's me 
see it, but the issue is that when I attempt to display the values in my 
.html template I simply get 
[object Object],[object Object],[object Object],[object Object],[object 
Object],[object Object],[object Object]

... just wondering what I have to do with my object to be able to use it in 
my .html template?

>From my html:
  <button class="btn btn-primary" (click)="onGet()">Get Concrete 
Orders</button>

<div *ngIf="results">{{results}} //this is where I get the [object Object] 
displayed on screen 7 times

    <div *ngFor="let result of results" style="border: thin solid silver;">
      {{result.id}}<br>
      {{result.crew}}<br>
      {{result.orderno}}<br>
      {{result.jobnumber}}<br>
      {{result.yards}}<br>
      {{result.delivery}}
    </div>
  </div>

And my service calling code:
getAllOrders(){
      return this.http.get('
http://127.0.0.1:8510/CFC/service.cfc?method=getAllOrders')
      .map(
        (response:Response) => {
          const data = response.json();
          return data;
        }
      );
  }

... and my component.ts code: 
onGet() {
    this.dataService.getAllOrders()
    .subscribe(
      (data: any[]) => this.results=data,
      (error) => console.log(error)
    );
  }

Thanks so much for your help and patience,

Rich

-- 
You received this message because you are subscribed to the Google Groups 
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to