There are some posts about this, but nothing specific that works in my project.
I read the docs on Breeze about Extending Entities, but they use knockout and I am using Angular.
I have defined a custom property on the server and it is being passed down in my JSON.
However, Breeze js ingnores it because there is no meta data for it.
I need to define the meta data on the client so that Breeze can read the property.
Here is what I have the client so far, but it does not work. By not working... I mean when I call it with {{item.MyProp}} nothing ever shows up on the screen. However, all the other properties from the actual meta data show up just fine.
configureBreeze();
var serviceName = 'api/Entity';
var manager = new breeze.EntityManager(serviceName);
manager.enableSaveQueuing(true);
var store = manager.metadataStore;
addMyPropType(store);
function addMyPropType(store) {
store.registerEntityTypeCtor("Merchant", MyProp);
}
// custom Merchant constructor
var MyProp= function () {
//'MyProp' is a server-side calculated property of the Merchant class
// This unmapped property will be empty for new entities
// but will be set for existing entities during query materialization
this.MyProp= "test";
};
var dataservice = {
store: store,
List: List,
Create: Create,
ListDetail: ListDetail,
Save: Save
};
return dataservice;
I have ready the NODB sample, but I do have a DB and it also uses KO.
UPDATE:
Ok. So I found something that partially works. The default value is now getting displayed on the view. However, the value from the JSON is not being filled in. It always uses the default value.
This is what I have now:
var Merchant = function () {
this.MyProp = "5";
};
store.registerEntityTypeCtor("Merchant", Merchant);
What needs to happen for MyProp to be filled by the actual value from the JSON?