Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can I use EJS with AngularJS?

Tags:

angularjs

ejs

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

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

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.

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?

How do I achieve these kind of things in Angular?

like image 730
Pyare Avatar asked Mar 12 '14 05:03

Pyare


People also ask

Does EJS support JavaScript?

EJS is a simple templating language that lets you generate HTML markup with plain JavaScript.

Is EJS a frontend framework?

EJS is a tool for generating web pages that can include dynamic data and can share templated pieces with other web pages (such as common headers/footers). It is not a front-end framework.

Is AngularJS better than NodeJS?

Node. JS is a useful tool to build fast and scalable server-side networking applications, while AngularJS is best suited for building single-page client-side web applications. Node. JS is an ideal language for developing small-size projects, and AngularJS is an ideal language for creating highly interactive web apps.


2 Answers

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.

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.

Similar questions:

  • Mixing angular and asp.net mvc webapi
  • Actual use of jade template and angularjs
like image 141
null Avatar answered Oct 23 '22 17:10

null


Yes of course you can use EJS with Angular JS. You might want to have a look at this;

https://gist.github.com/jrmoran/4277025

And about your DOM manipulation question. Yes you can append DOM dynamically using Angular JS. Angular JS have a strong feature of two way data binding which dynamically updates its DOM content when a model variable changes.

Have a look at this:

http://docs.angularjs.org/guide/databinding

like image 25
BKM Avatar answered Oct 23 '22 19:10

BKM