I\'ve recently started learning how to use Sails.js and I came across a small issue.
I have a model called Applicant, as follows:
module.exports = {
a
Try
<%= apps[applicant].name %>
It's just like for
loop works. applicant
is an index in apps
array.
Edit: Better way is to use javascript array's built in method forEach
, because this way you avoid cycling through elements, inherited from apps
's type (for example, elements, assigned like this: apps.__proto__.foo = {name: "bar"}
or Array.prototype.foo2 = {name: "pi222"}
).
<% apps.forEach(function(applicant) { %>
<li><%= applicant.name %> <%= applicant.email %></li>
<% }); %>
P.S. Of course this javascript's method (forEach
) wouldn't work in IE <= 8(if you consider to use it in browser). But we are inside NodeJs, which is built on top of V8 engine. So this will work, anyway.