Javascript 如何获取Ember中的路由路径类型
如果路由器地图中有:Javascript 如何获取Ember中的路由路径类型,javascript,jquery,ember.js,Javascript,Jquery,Ember.js,如果路由器地图中有: this.resource('detail', { path: '/detail/:type' }, function() { ... }); 我在我的余烬申请代码中检索到了currentPanth: currentPath: '', ApplicationController : Ember.Controller.extend({ updateCurrentPath: function() { App.set('currentPath',
this.resource('detail', { path: '/detail/:type' }, function() {
...
});
我在我的余烬申请代码中检索到了currentPanth:
currentPath: '',
ApplicationController : Ember.Controller.extend({
updateCurrentPath: function() {
App.set('currentPath', this.get('currentPath'));
console.log('currentPath',App.currentPath);
}.observes('currentPath')
}),
当我在我的应用程序中导航时,我通过控制台获得路由名称,但当它是“detail”时,我会得到“detail.index”。如何获取类型?您只能访问路由中的参数,即定义模型时:
App.Router.map(function() {
this.resource('photo', { path: '/photos/:photo_id' });
});
App.PhotoRoute = Ember.Route.extend({
model: function(params) {
return Ember.$.getJSON('/photos/'+params.photo_id);
}
});
或者您也可以使用,也可以仅在路线中使用
根据您想要完成的内容,可能更适合您什么是
类型
?资源名称?它是我要监视url更改的路径的参数。i、 e,从高级别路线进行集中监控。在我的应用程序的每个路径中都没有监控