How to make Node deliver a result that Angular can pick up ?

14 views
Skip to first unread message

Khiem Ngo

unread,
May 22, 2017, 12:12:33 PM5/22/17
to nodejs
Hello, I'm a newbie at Node and Angular.  I'm currently stumbling upon this problem:

Let's say the response from my Node server is an array of JSONs, like this:

students = [{"name" : "John Doe", "ID" : "12345", "major" : "math"},
                  {"name" : "Jame Smith", "ID" : "23456", "major" : "CS"},
                  {"name" : "Joe Green", "ID" : "34567", "major" : "EE"}]

In order to render this result using Angular, I would need the students array to be inserted in the Angular ng-init directive:

<div ng-init="students=[
                                     {"name" : "John Doe", "ID" : "12345", "major" : "math"},
                                     {"name" : "Jame Smith", "ID" : "23456", "major" : "CS"},
                                     {"name" : "Joe Green", "ID" : "34567", "major" : "EE"}
                                  ];">
   ...
</div>

How can I achieve this ?  Alternatively, if there is a better way to make Angular pick up the result that Node delivers, and continues with the rendering, please let me know.  Many thanks!

Reply all
Reply to author
Forward
0 new messages