我可以在AngularJS中使用EJS吗? [英] can I use EJS with AngularJS?

查看:77
本文介绍了我可以在AngularJS中使用EJS吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是AngularJS的新手.我已经使用JQuery和jQuery UI运行了出色的Web应用程序.

Hi I am new to AngularJS. I have great web app already running with JQuery and jQuery UI.

现在,由于MVC(MVW)模式,我想完全摆脱JQuery并迁移到Angularjs.

Now I want to completely get rid of JQuery and am going to migrate to Angularjs because of its MVC (MVW) pattern.

因此我的jQuery应用程序与EJS一起运行,用于模板和完全DOM操作.但是,当我想到Angular js时,我对此表示怀疑.我仍然可以使用EJS吗?

So my jQuery application is running with EJS for templates and entirely DOM manipulation. But when I think about Angular js, I have doubts. Can I still use EJS or not?

所以请指导我是否可以使用.

So please guide me whether I can use or not.

另一个疑问是,让我们假设我有列表页面.它是动态更新的,它将首先显示10条记录,然后根据用户滚动显示,接下来的10条记录将在AJAX之后添加到DOM中.我们可以使用Angular动态附加到DOM吗?

Another doubt is, let's assume I have list page. It is updated dynamically, and it will display 10 records first then based on user scroll, the next 10 records will be appended in the DOM after AJAX. Can we append to the DOM dynamically using Angular?

如何在Angular中实现这些目标?

How do I achieve these kind of things in Angular?

推荐答案

您可以将EJS(服务器端或客户端)与Angular结合使用,但没有必要,而且可能会使事情复杂化. AngularJS非常有能力以一种关注点分离的方式本身来操作DOM.使用Angular的最优雅的方法是拥有一个 RESTful 后端,并仅从Web服务器提供一些静态html/js文件.

You can use EJS (server or client side) in combination with Angular but there's no need and you'll probably overcomplicate things. AngularJS is very capable for manipulating the DOM by itself in a very separation of concerns kind of way. The most elegant way to work with Angular is to have a RESTful backend and just serve some static html/js files from a webserver.

对于无限滚动,有可供选择的大量可用插件(模块),或者您可以编写自己的插件.基本上,这需要使用 ng-repeat 此处找到简单的文章.

As for endless scrolling, there are tons of ready to use plugins (modules) to choose from or you can write your own. Basically this will need a view with a ng-repeat directive to display the currently loaded items and a directive that will notify a controller/scope to load more items when the user is scrolling down. A nice simple article can be found here.

类似的问题:

  • Mixing angular and asp.net mvc webapi
  • Actual use of jade template and angularjs

这篇关于我可以在AngularJS中使用EJS吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆