Created
April 18, 2013 22:15
-
-
Save engineersamuel/5416676 to your computer and use it in GitHub Desktop.
Example knockout expressions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- variable (usually a property of the current view model --> | |
<div data-bind="visible: shouldShowMessage">...</div> | |
<!-- comparison and conditional --> | |
The item is <span data-bind="text: price() > 50 ? 'expensive' : 'cheap'"></span>. | |
<!-- function call and comparison --> | |
<button data-bind="enable: parseAreaCode(cellphoneNumber()) != '555'">...</button> | |
<!-- function expression --> | |
<div data-bind="click: function (data) { myFunction('param1', data) }">...</div> | |
<!-- object literal (with unquoted and quoted property names) --> | |
<div data-bind="with: {emotion: 'happy', 'facial-expression': 'smile'}">...</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment