[英]How to transition to route in Ember from global context?
我正在将chrome扩展程序与ember应用程序集成。 我的app.js文件中有一些chrome扩展代码:
window.sendToExtension = (message, callback) => {
chrome.runtime.sendMessage(extensionId, message, (response) => {
console.log('got response from extension!!', response)
if (response.path) {
//Here I need to tell the ember app the transition to the given path
}
})
}
this
是指window
所以我不能只调用this.transitionTo
。 如何转换为扩展程序告诉我的路线名称?
我想到了!! 我要做的就是在执行window.applicationRouteInstance = this
的应用程序路由上添加一个beforeModel
钩子,然后可以全局访问该代码,例如在我的扩展消息传递代码中,以执行applicationRouteInstance.transitionTo(response.path)
另外还有2.3版中的新App.visit API
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.