Tutorialsplane

KnockoutJS Observables


KnockoutJS Observables Observables are special JavaScript objects that are used widely in KnockoutJS to handle the data exchange between view-model and view. Here in this tutorial we are going to explain how observables works in KnockoutJS.


KnockoutJS Observables | Syntax | Example

KnockoutJS basically works on the following three features-

Syntax

KnockoutJS Observables Syntax:

this.propertyName = ko.observable('value');

You can just make any property observable. ko is globally available once you include the KnockouJS library. ‘value’ will be assigned to the view model property ie. to propertyName.

Example

Now let us create very basic example to understand the observables-

KnockoutJS Observables Example:



   <title>KnockoutJS Example</title>
   


<div>

     <p>Hello Welcome to <span data-bind="text: helloText"><span></span></span></p>
</div>



Learn KnockoutJS