AngularJS and Handlebars - both required or not - angularjs

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 !

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

Related

AngularJS Routing All Within One HTML page

I am working with a serverless HTML so JavaScript cannot load other html content. I was wondering if there is an example of pulling the template from the DOM so that I can pack all my views into a single HTML file (i.e. without having to use string templates).
Would this work?
I am working with AngularJS 1.7.5 rather than the newer Angular 2.
I need it to work with Outlook/IE.
I was thinking of just getting the .InnerHTML of some base element. Advice, notes, concerns?

Template engine useful if using angular?

i am building a single page application using node.js and angular.js.
I wonder if there is any advantage on using a template engine like jade or ejs since angular has the ng-include directive which let you inject html partials inside your main html page, and of course with angular you have two-way data binding. Any thought on this?
It’s good idea to use Jade (or another template engine) for all html pieces in your project even if you’re creating SPA with AngularJS. Jade allows you to generate templates easy and fast. Templates will be neat and easy-to-read.
As for include directive, stick to the following rule in Angular+Jade projects: use Jade’s include for reusing pieces of html when you create static templates, use ng-include for dynamic purposes when partials depend on the App’s state.

jQuery code in Angular

I was forced to use jQuery code in Angular to hack a plugin that I need to use; should I put this code in the controller or in a <script> tag in the html (to have code that manipulates DOM close to the DOM)?
Its better you write your own custom directive. Please follow here at https://docs.angularjs.org/guide/directive.
You should keep the view logic separate either to HTML or to directives. Angular recommends this to keep your business logic separate from view logic.

What is meant by this Angularjs statement

I'm reading a book called Angularjs . In it this is stated "Angular traverses the template and looks for directives and bindings. This results in registration of listeners and DOM manipulation, as well as fetching initial data from the server. The end result of this work is that the app is bootstrapped and the template is converted into a view."
What is meant by "App is bootstrapped and the template is converted into a view." ?
I'm confused by what is meant by bootstrapping in this case ?
There is no main() method in AngularJS. When you create an angular application, you simply declare modules with controllers, directives, etc. When the page loads, angular looks for elements in the DOM with an attribute called 'ng-app', and if found, it boostraps, or starts if you prefer, the application.
See http://docs.angularjs.org/api/ng.directive:ngApp and http://docs.angularjs.org/guide/bootstrap

Using 3rd Party Javascript in AngularJS Partials?

I've making use of AngularJS Partial templates to create a dashboard. There is a listing view and when you click on an item, it switches to an Items-Detail partial.
Inside the Items detail partial, I'd like to show some charts via RGraph. However, for the life of me, I can't figure out how to do this.
I can't seem to invoke javascript from inside the partial html. So I think I need to do it in the controller, or maybe create a directive?
I'm pretty new to AngularJS so my understanding is still very rudimentary and likely misguided.
AngularJS ("jqlite") doesn't support <script> tags inside partials.
Include jQuery on your page, however, and it should work. Note that jQuery must be included before AngularJS.
See also AngularJS: How to make angular load script inside ng-include?

Resources