knockout/knockout — pull request #1666 by saynomoo (2014-12-29 12:12:56+00:00)
Title: Pass bindingContext as a parameter to the viewModel constructor

By providing the bindingContext to the viewModel constructor, we are able to create sub-components with less boilerplate code.

For example the live example 2, from page: http://knockoutjs.com/documentation/extenders.html could be done with components like this:

First register an auxiliar component, which assumes the model has a observable called value
```
ko.components.register('required-text', {
viewModel: function(params, bindingContext) {
this.visible = ko.pureComputed(function(){
return bindingContext.$rawData.value() == ""
})
},
template: 'This field is required'
});
```

Bind the context:
```
var appModel = {
firstName: {value: ko.observable("John")},
lastName: {value: ko.observable("Doe")}
}

ko.applyBindings(appModel);
```

With markup:
```

```

Currently the required-text -component would require passing parameters in the markup like:
```

```