I
I
Ivan Feofanov2015-07-30 14:11:11
Angular
Ivan Feofanov, 2015-07-30 14:11:11

How to display data - Sails.js / EJS or AngularJS?

Good afternoon
I'm doing a small educational project on Sails + Angular.
It is necessary to display data from the database, roughly speaking, a list of users registered in the system.
There are two options - to form a list and display it using Sails.js / EJS via

User
 .find()
 .exec(function(data){
   return res.view('users_view',{users:'users'});
})

and on the page, respectively,
<% users.forEach(user){%>
<li><%=user.name%></li>
<% } %>

or with Angular, accessing the store through the REST API, something like this:
$http
 .get('/user')
 .success(function(data){$scope.users = data})

and on the page
<div ng-repeat="user in users">
{{user.name}}
</div>

Which option would be the most reasonable?
Maybe you can suggest a third (fifth, twentieth) way?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
arbuzik, 2015-07-30
@arbuzik

Depending on how you are going to scale in the future. The second method is preferable, since you get clean data and in the future you can work with it as you like (filters, sorting, etc.)

V
Valentin Dubrovsky, 2015-07-30
@matroskin13

Please just don't interfere with the two view sources. Since you are using angular, then you have a spa, you should already display all the data through js.

E
e178551, 2017-08-23
@e178551

zdelayte gibrit. ispolzuyle sails soket mesto http ana na mnogo bistreye i dast vam instant funksional. broste vse template file v sailejs angularjd v acerts file. potom mojete sovmestit eta vse i polzitatsa lubim metodam v budushem. zagooglite angular sails ejs videl neskolko git repo naschet etogo.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question