angularjs - 为什么混合插值和表达式是不好的做法

标签 angularjs

来自文档:

Embedding interpolation markup inside expressions

Note: AngularJS directive attributes take either expressions or interpolation markup with embedded expressions. It is considered bad practice to embed interpolation markup inside an expression:

AngularJS Developer Guide - Interpolation

我正在寻找一个写得好的规范答案,我可以向读者指出。

最佳答案

来自文档:

Why mixing interpolation and expressions is bad practice:

  • It increases the complexity of the markup

  • There is no guarantee that it works for every directive, because interpolation itself is a directive. If another directive accesses attribute data before interpolation has run, it will get the raw interpolation markup and not data.

  • It impacts performance, as interpolation adds another watcher to the scope.

AngularJS Developer Guide - Interpolation

关于angularjs - 为什么混合插值和表达式是不好的做法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51592045/

相关文章:

javascript - 为什么 $scope 会改变整个页面的值?

javascript - AngularJS 资源未设置内容类型

javascript - 在 Win8 应用程序中使用 AppendTo/jquery-win8

mysql - Angularjs Node js mysql 增删改查

angularjs - 在 'Argument of type '类型中,如何解决}' is not assignable to parameter of type ' {]'. [ng] Property ' any [ '{}' length'丢失了。

javascript - 如何避免特定输入字段的键盘?

javascript - 使用 ng-class 的 AngularJS 切换类

javascript - AngularJS 摘要 postDigestQueue

angularjs - Angular-material - 在 md-select 多个选项中更改分隔符

javascript - Selenium click 不适用于 angularjs ng-click 事件