加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

ng-bind和ng-cloak之间的差异

发布时间:2020-12-17 09:27:33 所属栏目:安全 来源:网络整理
导读:在这个问题 why ng-bind is better than {{}} in angular? 我了解{{}}和ng-bind之间的区别.另一方面,我可以使用ng-cloak而不是ng-bind. 现在我的问题是ng-bind和ng-cloak之间有什么区别? 他们做相同的工作. 看看api文档,你可能会发现它们是什么. ngCloak Th
在这个问题 why ng-bind is better than {{}} in angular?
我了解{{}}和ng-bind之间的区别.另一方面,我可以使用ng-cloak而不是ng-bind.

现在我的问题是ng-bind和ng-cloak之间有什么区别?

他们做相同的工作.

看看api文档,你可能会发现它们是什么.

ngCloak

The ngCloak directive is used to prevent the Angular html template from being briefly displayed by the browser in its raw (uncompiled) form while your application is loading. Use this directive to avoid the undesirable flicker effect caused by the html template display.

ng-cloak指令是一个内置的角度指令,它隐藏了包含该指令的页面上的所有元素.

<div ng-cloak>
<h1>Hello {{ foo }}</h1>
</div>

浏览器完成加载和模板的编译阶段之后
渲染,角度将删除ngCloak元素属性和元素
将变得可见.

ngBind

The ngBind attribute tells Angular to replace the text content of the specified HTML element with the value of a given expression,and to update the text content when the value of that expression changes.

使用ng-bind而不是{{}}将阻止未呈现的{{}}显示,而不是呈现的空元素.上面的例子可以重写为以下,这将阻止
{{}}闪烁的页面:

<div>
<h1>Hello <span ng-bind="foo"></span></h1>
</div>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读