Sander
Thanks for your post, it was helpful and got me past this issue.
Now I have my service call only retrieving the DATA part of the JSON object
which helps.
I'm using this code in my service call:
getAllOrders(){
return
this.http.get('http://127.0.0.1:8510/CFC/service.cfc?method=getAllOrders')
.map(
(response:Response) => {
const data = response.json().DATA;
return data;
}
)
;
}
And it now returns:
1. (7) [Array(6), Array(6), Array(6), Array(6), Array(6), Array(6),
Array(6)]
1. 0:(6) [1, 160, 2, 1702377, 40, "Elm/Turrant Drive"]
2. 1:(6) [2, 44, 3, 1702391, 90, "2099 Steele Street"]
3. 2:(6) [3, 19, 5, 1702294, 30, "Mountain Medical - West Campus"]
4. 3:(6) [4, 66, 6, 1702364, 55, "Estes Regional Dev Center"]
5. 4:(6) [5, 69, 7, 1702272, 170, "Airport Blvd/South lot"]
6. 5:(6) [6, 102, 9, 1702321, 10, "Lakes/NE 44th"]
7. 6:(6) [7, 36, 10, 1702289, 80, "Boulder Tpk/Pecos"]
8. length:7
9. __proto__:Array(0)
However in my .html template I can only reference the results as a single
blob of data; when I loop over it I get blank values back.
How do I loop over these results from my service call? In my .html template
I'm currently using the following but as I said it's all blanks that I'm
getting back:
<div *ngIf="results">
<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>
If I simply use {{results}} I get everything, but I need to loop over and
display each row from the query in the JSON object.
Again thank you for your help, very appreciated!
Rich
On Sunday, December 17, 2017 at 11:21:23 PM UTC-7, Sander Elias wrote:
>
> Why don't you just loop over the `DATA` out of your result?
> or, if you don't care of the rest, use a map operator to narrow the result
> down like:
>
> httpClient.get('someUrl').pipe(map(resultJson => resultJson.DATA))
>
> Regards
> Sander
>
--
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.