双向绑定

通过引用传递值,你希望在两个范围之间共享值并从两个范围操作它们。你不应该使用{{…}}进行插值。

<two-way text="'Simple text.'" <!-- 'Simple text.' -->
         simple-value="123" <!-- 123 Note, is actually a number now. -->
         interpolated-value="parentScopeValue" <!-- Some value from parent scope. You may change it in one scope and have updated value in another. -->
         object-item="objectItem" <!-- Some object from parent scope. You may change object properties in one scope and have updated properties in another. -->
         
         <!-- Unexpected usage. -->
         interpolated-function-value="parentScopeFunction()" <!-- Will raise an error. -->
         function-item="incrementInterpolated"> <!-- Pass the function by reference and you may use it in child scope. -->
</two-way>

通过引用传递函数是一个坏主意:允许范围更改函数的定义,并且将创建两个不必要的观察者,你需要最小化观察者计数。