如何从不属于 aRoute
或的 JavaScript 函数中转换 Ember.js 应用程序Controller
?我可以直接调用route.transitionTo()
或controller.transitionToRoute()
使用Ember.Application
实例吗?
我想要做的是将 amMap 集成到Ember.js应用程序中,这样当点击地图上的某个区域时,应用程序就会转换到适当的状态。
这是一个示例 jsFiddle。当从列表中选择一个大陆时,该大陆在地图上被选中。我希望反过来也发生,我应该在以下听众中做什么:
map.addListener("homeButtonClicked", function () {
// how can I transition to index from here?
// similar to this.transitionTo("index") from a route or
// this.transitionToRoute("index") from a controller
alert("Transition to index");
});
map.addListener("clickMapObject", function (e) {
// how can I transition to continent from here?
// similar to this.transitionTo("continent", id) from a route or
// this.transitionToRoute("continent", id) from a controller
alert("Transition to continent: " + e.mapObject.id);
});