Reputation: 7688
I have the following code with some knockout syntax:
<h2 data-bind="text: $root[$root.primaryKey]() ? 'Edit' : 'Create New'"></h2>
Based on the same syntax $root[$root.primaryKey]()
I want to do a simple if syntax check for another div so I know what to show, an updatable content or to the form to add a new article.
So, how could I do something like
if $root[$root.primaryKey]()
<div> update content </div>
else
<div> new content </div>
Upvotes: 0
Views: 342
Reputation: 16465
You could use virtual elements:
<!-- ko if: $root[$root.primaryKey]() -->
<div> update content </div>
<!-- /ko -->
<!-- ko ifnot: $root[$root.primaryKey]() -->
<div> new content </div>
<!-- /ko -->
Upvotes: 2