문제

I'm writing cordova + angular + breeze app where text info from element should be stored in the cash of browser that wraps the app. Accordind to the docs to do so, first I need to create new entity type in breeze. I do the following:

var entityManager = new breeze.EntityManager("api/Northwind");
var newType = new breeze.EntityType({
    shortName: "input"
});

Next I'm trying to create new entity of this type:

var newEntity = newType.createEntity();

This fails with message: "TypeError: Cannot read property '_ctorRegistry' of undefined"

Is seems to be very basic functionality of breeze but I can't get it work for 2 days already. Could anyone help me with that?

도움이 되었습니까?

해결책

After created new EntityType, you should attach it to metadataStore to create entities of new type. Your code should look:

var metadataStore = new breeze.MetadataStore();
entityManager= new breeze.EntityManager({
            serviceName: "api/db",
            metadataStore: metadataStore
        });

// if you call fetchMetadata()
entityManager.fetchMetadata().then(function(){
    var newType = new breeze.EntityType({
        shortName: "input"
    });

    entityManager.metadataStore.addEntityType(newType);

    newType.createEntity(...);
    // ...
});

//or just use var metadataStore
var newType = new breeze.EntityType({
    shortName: "input"
});

entityManager.metadataStore.addEntityType(newType);

newType.createEntity(...);
// ...
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top