如何在Ember中获取路径类型
How to get the type of route path in Ember
如果我在路由器映射中有:
this.resource('detail', { path: '/detail/:type' }, function() {
...
});
我在我的Ember应用程序代码中检索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);
}
});
或者你也可以使用paramsFor,也只是在路线中。
根据您试图简化的内容,查询参数可能更适合
相关文章:
- 如何在Ember中获取路径类型
- 从“另存为浏览器”对话框中获取路径
- SVG:获取路径的精确边界框
- jQuery 从数据属性获取路径
- SVG文件 :如何使用Inkscape将PNG文件转换为SVG文件后获取路径标记数据
- 节点.js:从请求中获取路径
- Instagram照片获取路径并保存到数据库中
- 没有基本href,我如何获取路径
- KineticJS-获取路径形状的宽度/高度
- 如何从phonegap的html5输入字段文件对象获取路径
- Raphael-获取路径的ID和名称
- Sammy.js-从路由中获取路径
- 正在获取路径的属性
- 如何从javascript对象的键和值获取路径
- 使用javascript从URL获取路径和查询字符串
- JSON不使用ajax获取路径
- 正在获取'路径未找到'使用CreateTextFile时
- SVG:如何制作路径/获取路径的点
- 在SVG中获取路径的维度
- 使用Google地图api获取路径点数组