Observable arrays
Usual observables allow us to create some property for which Knockout.js detects any changes. However, what if we want to work with a collection of objects and detect add and remove operations? The Knockout.js solution is observable arrays. We can use this special kind of arrays with the help of ko.observableArray
. In this section, we will discuss how to use it in general, how to add new elements in an observable array, how to remove elements, and some useful manipulation functions for observable arrays.
Using an observable array
Very often, the real ViewModel objects contain collections of some elements. In this section, we will consider a very simple example with a collection in the ViewModel to demonstrate observable array usage. ...
Get Getting Started with Knockout.js for .NET Developers now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.