You haven't provided enough info, but we can safely assume one of two situations:
- Plain properties:
DtCntrctDlvry = 0; or
- Observables:
DtCntrctDlvry = ko.observable(0)
Binding handlers don't care which it is if you do simple bindings, e.g.:
<span data-bind="text: DtCntrctDlvry"></span>
But they do care if you start putting logic in there. Above situations respectively require:
Plain properties:
<span data-bind="text: DtCntrctDlvry === 0 ? 'a' : 'b'"></span>
Observables:
<span data-bind="text: DtCntrctDlvry() === 0 ? 'a' : 'b'"></span>
In any case, please see my answer to another question where I argue that you would be off even better if you wrap the logic inside a computed, e.g.:
var ViewModel = function() {
var self = this;
self.DtCntrctDlvry = ko.observable(0);
self.DtCntrctDlvryText = ko.computed(function() {
return self.DtCntrctDlvry() === 0 ? "a" : "b";
});
}
And bind like this:
<span data-bind="text: DtCntrctDlvryText"></span>
PS. Some footnotes:
- Do you realize you're using
== where you might prefer ===?
- Any reason you're writing
'0' (zero, but as a string) instead of 0 (as a number)?
In my answer I've assumed the for both cases you meant to use the latter. If not, you may have to tweak my solution for that.
text: DtCntrctDlvry() == '0' ? 'a' :'b'DtCntrctDlvry(crazy name btw) is an observable, then it's never going to equal'0'because observables aren't strings, they're observables. Get the backing value by calling the observable as a function and then compare that with'0'.