Warm tip: This article is reproduced from serverfault.com, please click

Why mixing interpolation and expressions is bad practice

发布于 2018-07-30 10:35:08

From the Docs:

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

I am looking for a well written canonical answer to which I can point readers.

Questioner
georgeawg
Viewed
0
2020-06-20 17:12:55

From the Docs:

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