The Text binding

Text binding useful to display text without any html element (plain text). According to HTML , normally we write text inside span or p tag but it can be used with any element.

Important note is that it will overwritten previous text and it will consider html element as plain text if written.

Let’s go for an example and check how in different conditions and variously uses.



Simple Example:

In above example, we have bind stockMessage as text with initial value as “Out of stock”.

Condition based Example:

in below example, we have put condition, based on that it changes the stockMessage observable.

We can also use Container less syntax. What it is? Question ?
It’s simple instead of data-bind inside of HTML element we can write like this.

Directly can use knockout observable to same logic of condition based message.

Leave a Reply