I have an Ember.Controller , with installation code in the init function. Actually this code makes AJAX requests. But when I create two instances of this controller, they are always equal. Why, and what can I do it again?
I made this simple example that shoud writes Test 1 Test 2 in the console. Bit it record Test 2 twice.
App = Em.Application.create({}); App.TestController = Em.Controller.extend({ content: Em.Object.create({ info: null, }), init: function() { if(this.id == 1) { this.content.set('info', "Test 1"); } if(this.id == 2) { this.content.set('info', "Test 2"); } }, }); var c1 = App.TestController.create({id: 1}); var c2 = App.TestController.create({id: 2}); console.log('C1: ' + c1.get('content').get('info')); console.log('C2: ' + c2.get('content').get('info'));โ
Lux
source share