Binding Wildcard to Observable

You can bind the wildcard ID to an observable. Using the nameParam property you can either specify the name of the observable to bind to (or create) or directly specify an observable.

Navigate to some sub page

Here the observable theID is defined in the view model but the observable theSecondID is not specified in the view model.

var viewModel = {
    theID: ko.observable('')
};

Since the observable theID is specified in the view model it must be referenced as normal, but since the theSecondID is not defined in the view model it must be defined using a string ('theSecondID'). Otherwise the binding would try to get the value of an undefined field.

<div data-bind="page: {id: '?', nameParam: theID}">

    <div data-bind="page: {id: '?', nameParam: 'theSecondID'}">
        <h2 data-bind="text: theID"></h2>
        <h3 data-bind="text: theSecondID"></h3>
    </div>
</div>