Components of KnockoutJS

Components are way of organizing the UI code for structure wise and promote code re-usability for a large application. Components can be registered using the ko.components.register() API. ko.components.register(‘componentname’, { viewModel: {…}, template: {….) }); <!DOCTYPE html> <head> <title>Components of KnockoutJS</title> <script src=”https://cdnjs.cloudflare.com/ajax/libs/knockout/3.2.0/knockout-min.js”></script> </head> <body> <h4>Example 1: without parameters</h4> <div data-bind=’component: “example-editor”‘></div> <h4>Example 2: passing parameters</h4> […]

KnockoutJS – Observables

3 concepts in which KnockoutJS is build upon is: – Through observables dom elements and ViewModel exchange information – Bindings between UI and ViewModel – Templating web applications To make it observable declare as: this.property = ko.observable(‘value’); Let’s try below Observables example: <!DOCTYPE html> <head> <title>KnockoutJS – Observables</title> <script type=”text/javascript” src=”http://ajax.aspnetcdn.com/ajax/knockout/knockout-3.1.0.js”></script> </head> <body> <!– This […]