ifnot binding

The "ifnot" binding

Purpose

The ifnot binding is exactly the same as the if binding, except that it inverts the result of whatever expression you pass to it- For more details, see documentation for the if binding.

Note: “ifnot” is the same as a negated “if”

The following markup:

<div data-bind="ifnot: someProperty">...</div>

… is equivalent to the following:

<div data-bind="if: !someProperty()">...</div>

… assuming that someProperty is observable and hence you need to invoke it as a function to obtain the current value.

The only reason to use ifnot instead of a negated if is just as a matter of taste: many developers feel that it looks tidier.

© Steven Sanderson, the Knockout.js team, and other contributors
Licensed under the MIT License.
http://knockoutjs.com/documentation/ifnot-binding.html

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部