Want to access property of controller from within view? Ember will set a view’s controller property when the view is created, you can use that to access the controller’s property.
1 2 3 4 5 6 7 8 9 10 11 12 | App = Ember.Application.create(); App.ApplicationController = Ember.Controller.extend({ percentComplete: '0' }); App.ProgressView = Ember.View.extend({ percentChanged: function() { percentString = (this.get('controller.percentComplete') + "%"); this.$('.bar').css('width', percentString); }.observes('controller.percentComplete').on('didInsertElement') }); |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.