I am integrating a chrome extension with an ember app. I have some chrome extension code in my app.js file:
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
refers to window
so I can't just call this.transitionTo
. How can I transition to the route name the extension has told me to?
I figured it out!! All I had to do was add a beforeModel
hook to the application route that did window.applicationRouteInstance = this
and then I can access this globally, such as in my extension messaging code, to do applicationRouteInstance.transitionTo(response.path)
Also there's the new App.visit api coming in 2.3
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.