ejs跟angularjs相比,实在是太难写了,附实例!
例如一段以下代码的实现
判断
ejs
<% if (data.success) { %>
<span><%= data.success %></span>
<% } %>
<% if (data.err) { %>
<span><%= data.err %></span>
<% } %>
angularjs
<span>{{ data.success }}</span>
<span>{{ data.err }}</span>
遍历
var arrs = [{name:a, age:10}, {name:b, age:20}];
ejs
<% arrs.forEach(function (v, k){ %>
<span><%= v.name %></span>
<span><%= v.age %></span>
<% }) %>
angularjs
<div ng-repeat="arr in arrs">
<span>{{ arr.name }}</span>
<span>{{ arr.age }}</span>
</div>
10 回复