Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/471.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何获取Ember中的路由路径类型_Javascript_Jquery_Ember.js - Fatal编程技术网

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,从高级别路线进行集中监控。在我的应用程序的每个路径中都没有监控