I'm having hard time to make the difference between view template engines, such as EJS and AngularJS. I do understand concept behind view template engines, but I was thinking that Angular is pretty much the same. While building project with IntelliJ, it offered me to make structure of application which is provided by express and to chose view template engine. Since I'm not bothered with HTML syntax, I went with EJS rather than Jade. Now, since I have more user roles, I need to change the view according to role of the user. I tried to do it with EJS with control flow (if-then), but found documentation on EJS really poor. That's why I decided to check the AngularJS since all my colleagues are using it.
As far as I understand till now, I'll have controllers in AngularJS which can control how the view should look like and which data should be filled in.
Do I need view template engine when using AngularJS at all? Are there any benefits?
My code makes use of routes
and looks somehow like this now:
/* GET /register page. */
router.get('/', function(req, res) {
res.render('enter.html');
});
(I've made .html extension to be rendered with EJS)
So, I won't use res.render() anymore and will make usage of controllers and views supported with AngularJS?
In my experience with Angular your web server exposes an API and serves static files, that's it. No need to construct HTML responses with server side processing, just serve the data your application needs. I tend to think of my Angular client as disconnected from the backend as any other client (iOS, Android, etc).
you can see Express.js as server side app or server which listens for client requests, assembles the html page and sends it as reply to client. Similar to let's say Codeigniter in PHP world. You can user plain HTML or you can use Jade or other templating language.
On other hand AngularJs is client side technology. You use it to create what is called single web application which means that DOM modification is happening on client side and the app exchange with server only data. If your concern is template it is plain html.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With