AngularJS 和 Handlebars - 是否都需要 [英] AngularJS and Handlebars - both required or not

查看:26
本文介绍了AngularJS 和 Handlebars - 是否都需要的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道前端是否使用AngularJS作为js框架,模板引擎是否需要单独的Handlebars?...在我看来,模板引擎功能可以使用 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 !

推荐答案

你说得对,将 Handlebars 和 Angular 放在一起将毫无用处.

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

Handlebars 和 Angular 是完全不同的东西.

Handlebars and Angular are completely different things.

Handlebars 是一个模板引擎.你编写一个花哨的模板字符串,给它一个 JSON 对象,然后它从数据中渲染出 HTML.没有数据绑定,没有更新,它只是一次性渲染.

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 是一个 HTML 编译器和数据绑定器.Angular 将通过 HTML 查找角度模板标签,解释/编译它们,并根据给定控制器范围内的数据更改更新 HTML.Angular 不仅仅渲染一次 HTML 字符串,它还编译 HTML,将其绑定到作用域,并在该作用域上的数据发生变化时进行更新.

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.

一张图片中的把手

AngularJS 数据绑定/模板化一张图

一篇文章中的AngularJS的HTML编译器

AngularJS 的整个概述/指南,因此您可以了解它的实际工作原理

这篇关于AngularJS 和 Handlebars - 是否都需要的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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