Thursday, 15 May 2014

ember.js - Using Ember CLI Addon Models in Ember Application? -


I want to allow the following to work in my application:

Find the store ('my-addon.my-addon-model', 1)

store.find ('my-addon / my-addon-model', 1) < / Code>

store.find ('my-addon: my-addon-model', 1) (unexpectedly)

Want to search for 100% defined models in an app.

Import MyAddonModel from 'my-addon / models / my-addon-model' Works from within my app -

This question The same way:

However, there is some confusion in naming. Even when trying it, I even start hitting a bug in ember-data@1.0.0-beta.15.

What you need to do in your module initiator register the model (s) in your application.

  import 'amber' from amber; Import myMold with my-module / model / mine-model; Export Default {Name: 'my-module-models', initialize: function (container, app) {// One of these calls is required for each model to register the application. Registration ('model: myModule.myModel', MyModel); }}; According to my experience with Amber and Amber-Data, it works like this. But in my setup, with ember-data@1.0.0-beta.15, there is an issue to determine the model "key" after the creation model example is fine, but you try to save a model Will kill the error. 

I've got a quick solution, but this is a hack and I'll need to check further if I remember one step or it's a bug. The workaround includes setting of "type" of the class, resulting in:

  Import MyModel - from my module / model / my model; Export Default {Name: 'my-module-models', initialize: function (container, app) {// One of these calls is required for each model to register the application. Registration ('Model: myModule.myModel', MyModelreopenClass ({typeKey: 'myModule.myModel'})); }}; Finally, there is another way around when you create modules in Amber-Klee, you have an app folder that will be merged with the app using your module. You can provide the default detail of your model in the App folder. 


No comments:

Post a Comment