ember.js

Injecting session into a model

試著忘記壹切 提交于 2020-01-11 04:20:06
问题 I'd like to be able to inject my Session singleton into my Ember models. The use case I'm trying to support is having computed properties on the model that react to the user's profile (a property on the Session object). App = window.App = Ember.Application.create({ ready: function() { console.log('App ready'); this.register('session:current', App.Session, {singleton: true}); this.inject('session:current','store','store:main'); this.inject('controller','session','session:current'); this.inject

Exclude folders from builds in Brocfile

試著忘記壹切 提交于 2020-01-11 00:11:35
问题 Is there a way to exclude a folder from a build in a Brocfile (or any other place). The use case is packaging, where I have an app made of sub-apps within pods. eg. /app/modules/components /app/modules/app1 /app/modules/app2 /app/modules/app3 I'd like to build them all when environment is set to 'development' or only eg. 'app1' when environment is 'app1'. Any suggestions? I have tried different combinations of broccoli-file-remover, broccoli-funnel and broccoli-merge-trees to no avail. var

EmberJS: Good separation of concerns for Models, Stores, Controllers, Views in a rather complex application?

余生颓废 提交于 2020-01-10 14:18:25
问题 I'm doing a fairly complex emberjs application, and tying it to a backend of APIs. The API calls are not usually tied to any particular model, but may return objects of various types in different sections of the response, e.g. a call to Events API would return events, but also return media assets and individuals involved in those events. I've just started with the project, and I'd like to get some expert guidance on how best to separate concerns to have a clean maintainable code base. The way

EmberJS: Good separation of concerns for Models, Stores, Controllers, Views in a rather complex application?

陌路散爱 提交于 2020-01-10 14:16:16
问题 I'm doing a fairly complex emberjs application, and tying it to a backend of APIs. The API calls are not usually tied to any particular model, but may return objects of various types in different sections of the response, e.g. a call to Events API would return events, but also return media assets and individuals involved in those events. I've just started with the project, and I'd like to get some expert guidance on how best to separate concerns to have a clean maintainable code base. The way

Emberjs async routing

感情迁移 提交于 2020-01-10 08:55:30
问题 My problem is related with the issues #1183 and #1268 of emberjs. I have dynamic element at routes. All is ok if I navigate throuht application. The problem is when I reload a page or when a type the url. In that case the app enter in the deserialize function and load and object by their id, but this load is asynchronous. At issue #1268 lukemelia says "you will need to make the result of your deserialize method implement the promises pattern" . I try it but always loose context. My code is

Why aren't my templates rendering

拈花ヽ惹草 提交于 2020-01-10 05:27:26
问题 I've created some random views with the latest transition stuff from ember and the outlets aren't rendering. It's saying it's transitioning, but nothings showing up in the output window. (Note this works if I completely remove the routes) Here it is: jsfiddle to example App.PageRoute = Em.Router.extend({ model: function(params, transition){ return App.Page.find(params.page_id); } }); Does it have to do with promises? Am I supposed to be returning a promise instead of the actual model? 回答1:

create temporarty non persistent object in Ember-Data

流过昼夜 提交于 2020-01-10 02:57:32
问题 I want create an object using ember-data, but I don't want to save it until I call commit. How can I achieve this behavior? 回答1: You can use transaction 's, defined transaction.js with corresponding tests in transaction_test.js. See an example here: App.store = DS.Store.create(...); App.User = DS.Model.extend({ name: DS.attr('string') }); var transaction = App.store.transaction(); transaction.createRecord(App.User, { name: 'tobias' }); App.store.commit(); // does not invoke commit transaction

Ember.js: HtmlBars and the Handlebars.compile command

*爱你&永不变心* 提交于 2020-01-10 01:40:06
问题 I get the following error when running my app: Uncaught Error: Cannot call `compile` without the template compiler loaded. Please load `ember-template-compiler.js` prior to calling `compile`. It is related to this piece of code: var CarouselView = Ember.View.extend({ template: Ember.Handlebars.compile('{{view view.itemsView}}'), elementId: 'carousel', contentBinding: 'content', ... There is already an issue related about this problem on ember.js github: https://github.com/emberjs/ember.js

How to pass API keys in environment variables to Ember CLI using process.env?

落花浮王杯 提交于 2020-01-09 12:50:14
问题 How do I pass environment variables from bashrc to Ember CLI. I imagine a situation where you need stripe api keys or pusher api-keys and you have them in your environment variables in bashrc. How do you pass the api-keys to Ember CLI. I tried using Node.js process.env in both the brocfile.js and environment.js , but when I try to access it in the Ember JS controller, the property is null. In my environment.js file I added, APP: { apiKey: process.env.KEY } In My Ember JS controller I tried

Ember - What's the difference between controller's content and model property

自闭症网瘾萝莉.ら 提交于 2020-01-09 09:36:41
问题 In ember's official guide, it provides two ways to set the controller's underlying object. First is setting the model property: App.SongsRoute = Ember.Route.extend({ setupController: function(controller, playlist) { controller.set('model', playlist.get('songs')); } }); Second is setting the content property: MyApp.listController = Ember.ArrayController.create(); $.get('people.json', function(data) { MyApp.listController.set('content', data); }); Are these two properties represent the same