根据文档:
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/