路线非常简单:
App.Router.map(function() {
this.resource('users', {path: '/'}, function() {
this.resource('user', {path: '/user/:user_id'});
});
});
和以下模板:
# application
.container= outlet
# users
.left
ul.users-list= each controller
li= link-to 'user' this
= fullName
.main
= outlet
# users/index
p please select user from the list
是否可以获取当前应用程序状态?例如,知道usersIndexRoute
活动的(某种空白状态)以.main
不同的样式会很有用。优选地,我想在应用程序视图中具有此状态,例如,在中绑定.container
。
使用currentPath
的ApplicationController
取得和将其绑定到类的当前路线路径container
:
App.ApplicationView = Ember.View.extend({
classForPath: (function() {
var currentPath = this.get('controller.currentPath') || '';
currentPath = Ember.String.decamelize(currentPath);
currentPath = currentPath.split('.').join('-');
return currentPath;
}).property('controller.currentPath')
});
<div {{bindAttr class=":container view.classForPath"}}>
{{outlet}}
</div>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句