javascript - Best way to wrap ember-data models with their controllers -


I have a custom view with the renderer function, which needs to be calculated, since I have all my performance logic and properties It is useful to "wrap" your model with the controller to manually get some modue properties, but there is a better / cleaner way No Land? The current code in view is:

  ... currentPage = pages.filterBy ('nr', pageNb) .get ('firstObject') currentPageCntl = @ cntl.get ('Controller page' ). Set ('model', current page) current page delimations = current page Cntl.get ('dimension') ...    

So if I understand you correctly, then you have the logic and the data that you do not want to include in your model, even if they are in some places together. I'm actually working on an issue just like this issue. I do not know that this is the best way to do the job, but the way I am doing this is to wrap the amber data model. It is such an object that offers the model more closely that you want. For example, what this might look like for you:

  App.Page = DS.Model.extend App.PageWrapper = Ember.Object.extend Page: Zero Dimension: () -> ; # ... .property ('Page')   

So for your application, do not treat page as your model, Use the. Change your model to your current page as your model:

  currentPage = App.PageWrapper.create Page: pages.filterBy ('nr' , PageNb) .get ('firstObject')   

In this way, you can add whatever logic / model you want the wrapper class, but keep it separate from your page. If you give me some more information then I can help you come up with more amber, but this is a completely legitimate solution.

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -