Knockout fromJS simple example

Define a view model;

var mappedViewmodel = ko.mapping.fromJS({
            name: 'Shahzad Khan',
            age: 55
        });
        ko.applyBindings(mappedViewmodel, document.getElementById("simpleData"));

Display on page;

<div class="col-sm-6">
    <h3 class="text-left">Knockout fromJS simple example</h3>
        <div id="simpleData">
            <p>name: <label data-bind="text: name" /></p>
            <p>age: <label data-bind="text: age" /></p>
        </div>
</div>

Another good tutorial is here

https://bsscommerce.com/confluence/knockout-js/

Read more here

FavoriteLoadingAdd to favorites
Spread the love

Author: Shahzad Khan

Software developer / Architect