Do you want to know the current path in your Ember.js app? This was asked on Stack Overflow recently and I thought it was a neat trick.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App = Ember,Application.create({ | |
currentPath: '' | |
}); | |
ApplicationController : Ember.Controller.extend({ | |
currentPathDidChange: function() { | |
App.set('currentPath', this.get('currentPath')); | |
}.observes('currentPath') | |
}); |
Now you can access your current path from anywhere with:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App.get('currentPath'); |