Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AngularJS and Handlebars - both required or not

I need to know if AngularJS is used as js framework for the front-end, do we need Handlebars separately for template-engine? ... as in my view template-engine functionality can be accomplished using AngularJS itself !

like image 590
Kaushik Shrestha Avatar asked Nov 26 '12 08:11

Kaushik Shrestha


People also ask

Does AngularJS use handlebars?

Handlebars and Angular are completely different things. Handlebars is a template engine. You write a fancy templatey-string, give it a JSON object, and it renders out HTML from the data.

Is handlebars frontend or backend?

Handlebars is popular for both back-end and front-end templating. For example, the popular front-end framework Ember uses Handlebars as the templating engine. Handlebars is an extension of the Mustache template language, which is mostly focused on simplicity and minimal templating.

Why do we need handlebars?

The most important use of Handlebars, and any templating engine, is to keep your HTML pages simple and clean and decoupled from the logic-based JavaScript files, and Handlebars serves this purpose well. Indeed, Dust. js is also a logic-less templating engine and a worthy alternative to Handlebars.


1 Answers

You are right, Handlebars and Angular together would be pretty useless.

Handlebars and Angular are completely different things.

Handlebars is a template engine. You write a fancy templatey-string, give it a JSON object, and it renders out HTML from the data. There's no data-binding, no updating, it's just a once-off render.

AngularJS is an HTML compiler and databinder. Angular will look through the HTML for angular-templating tags, interpret/compile them, and update the HTML with changes to data on a given controller scope. Angular doesn't just render an HTML string once, it compiles the HTML, binds it to a scope, and updates when data on that scope changes.

Handlebars in one picture

AngularJS databinding/templating in one picture

AngularJS's HTML compiler in one article

AngularJS's whole overview/guide, so you can know how it actually works

like image 151
Andrew Joslin Avatar answered Oct 02 '22 02:10

Andrew Joslin