gpt4 book ai didi

javascript - ngBindTemplate 和 ngBind 有什么区别?

转载 作者:行者123 更新时间:2023-11-28 08:37:17 25 4
gpt4 key购买 nike

根据文档:

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.

The ngBindTemplate directive specifies that the element text content should be replaced with the interpolation of the template in the ngBindTemplate attribute. Unlike ngBind, the ngBindTemplate can contain multiple {{ }} expressions. This directive is needed since some HTML elements (such as TITLE and OPTION) cannot contain SPAN elements.

我的解释是 ngBindTemplate 可以完成 ngBind 所做的一切,甚至更多。那么为什么我们还要有 ngBind 呢?

最佳答案

正如您在 sources 中看到的那样,ngBindTemplate涉及$interpolate服务,其中:

Compiles a string with markup into an interpolation function. This service is used by the HTML $compile service for data binding.

关于javascript - ngBindTemplate 和 ngBind 有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20962112/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com