ngHide
KnockoutJS 中没有直接的等效绑定。然而,由于隐藏只是显示的反面,我们可以反转 Knockout 的 ngShow
等效的例子 。
<p ng-hide="SomeScopeProperty">This is conditionally shown.</p>
KnockoutJS 等价物:
<p data-bind="visible: !SomeScopeObservable()">This is conditionally hidden.</p>
上面的 KnockoutJS 示例假设 SomeScopeObservable
是一个可观察的,并且因为我们在表达式中使用它(因为它前面的 !
运算符),我们不能在末尾省略 ()
。