[EmberJS]:在 child 模板中获取选定模型
[EmberJS]: Get selected model in child template
我是 Ember 的新手,想在 child controller/template 中获取选定的模型值。
我有一个列出工作区的边栏。每当有人单击工作区时,应用程序都会路由到 workspaces/:slug
并显示连接到该特定工作区的任务列表。
我想在 child 路径中显示选定的工作区 name
。我该怎么做?
我的路由器是这样的:
App.Router.map(function() {
this.route('login');
this.resource('workspaces', function() {
this.route('tasks', {path: ':slug'});
});
});
在网上看了很多东西,但还没有完全弄明白。
谢谢。
:slug
是您的动态细分。您可以像这样访问 model
挂钩中的动态段:
App.WorkspacesTasksRoute = Ember.Route.extend({
model: function(param) {
return { name: param.slug };
}
});
查看有效的 jsbin 示例 here
我是 Ember 的新手,想在 child controller/template 中获取选定的模型值。
我有一个列出工作区的边栏。每当有人单击工作区时,应用程序都会路由到 workspaces/:slug
并显示连接到该特定工作区的任务列表。
我想在 child 路径中显示选定的工作区 name
。我该怎么做?
我的路由器是这样的:
App.Router.map(function() {
this.route('login');
this.resource('workspaces', function() {
this.route('tasks', {path: ':slug'});
});
});
在网上看了很多东西,但还没有完全弄明白。
谢谢。
:slug
是您的动态细分。您可以像这样访问 model
挂钩中的动态段:
App.WorkspacesTasksRoute = Ember.Route.extend({
model: function(param) {
return { name: param.slug };
}
});
查看有效的 jsbin 示例 here