I'm having trouble creating computed values in Breeze and binding to them with Knockout.
I'm working with the NoDb sample project, which can be download here and Extending Entities article in the Breeze documentation has been my main source of information.
In the todo.datacontext.js file, I have made the following changes: (I've included the first and last lines to give guidance as to where exactly I've placed the code)
...
configureManagerToSaveModifiedItemImmediately();
metadataStore.registerEntityTypeCtor('TodoItem', function () { }, todoItemInitializer);
function todoItemInitializer(todoItem) {
todoItem.participantName = ko.computed(function () {
return 'John' + ' ' + 'Smith';
});
};
var datacontext = {
...
And in Index.html, I added:
...
<ul data-bind="foreach: todos">
<li>
<p data-bind="text: participantName" />
<input type="checkbox" data-bind="checked: isDone" />
...
However, I'm getting this error:
Error retrieving todo lists: Unable to parse bindings. Message: ReferenceError: participantName is not defined; Bindings value: text: participantName
I've also noticed, if I execute this:
metadataStore.getEntityType('TodoItem');
It's telling me that such a type doesn't exist, even though I'm registering it.
Any ideas?